@@ -87,6 +87,148 @@ def test_to_many_recipients(self):
8787 assert email .to [2 ].email == "user3@example.com"
8888 assert email .to [2 ].name is None
8989
90+ def test_cc_array_functionality (self ):
91+ """Test CC with array input"""
92+ cc_recipients = [
93+ {"email" : "cc1@example.com" , "name" : "CC User 1" },
94+ {"email" : "cc2@example.com" , "name" : "CC User 2" },
95+ {"email" : "cc3@example.com" }, # No name
96+ ]
97+
98+ email = (
99+ EmailBuilder ()
100+ .from_email ("sender@example.com" )
101+ .to ("recipient@example.com" )
102+ .cc (cc_recipients )
103+ .subject ("CC Array Test" )
104+ .text ("Test message" )
105+ .build ()
106+ )
107+
108+ assert len (email .cc ) == 3
109+ assert email .cc [0 ].email == "cc1@example.com"
110+ assert email .cc [0 ].name == "CC User 1"
111+ assert email .cc [1 ].email == "cc2@example.com"
112+ assert email .cc [1 ].name == "CC User 2"
113+ assert email .cc [2 ].email == "cc3@example.com"
114+ assert email .cc [2 ].name is None
115+
116+ def test_bcc_array_functionality (self ):
117+ """Test BCC with array input"""
118+ bcc_recipients = [
119+ {"email" : "bcc1@example.com" , "name" : "BCC User 1" },
120+ {"email" : "bcc2@example.com" , "name" : "BCC User 2" },
121+ {"email" : "bcc3@example.com" }, # No name
122+ ]
123+
124+ email = (
125+ EmailBuilder ()
126+ .from_email ("sender@example.com" )
127+ .to ("recipient@example.com" )
128+ .bcc (bcc_recipients )
129+ .subject ("BCC Array Test" )
130+ .text ("Test message" )
131+ .build ()
132+ )
133+
134+ assert len (email .bcc ) == 3
135+ assert email .bcc [0 ].email == "bcc1@example.com"
136+ assert email .bcc [0 ].name == "BCC User 1"
137+ assert email .bcc [1 ].email == "bcc2@example.com"
138+ assert email .bcc [1 ].name == "BCC User 2"
139+ assert email .bcc [2 ].email == "bcc3@example.com"
140+ assert email .bcc [2 ].name is None
141+
142+ def test_cc_many_method (self ):
143+ """Test cc_many method"""
144+ cc_recipients = [
145+ {"email" : "cc1@example.com" , "name" : "CC User 1" },
146+ {"email" : "cc2@example.com" , "name" : "CC User 2" },
147+ ]
148+
149+ email = (
150+ EmailBuilder ()
151+ .from_email ("sender@example.com" )
152+ .to ("recipient@example.com" )
153+ .cc_many (cc_recipients )
154+ .subject ("CC Many Test" )
155+ .text ("Test message" )
156+ .build ()
157+ )
158+
159+ assert len (email .cc ) == 2
160+ assert email .cc [0 ].email == "cc1@example.com"
161+ assert email .cc [0 ].name == "CC User 1"
162+ assert email .cc [1 ].email == "cc2@example.com"
163+ assert email .cc [1 ].name == "CC User 2"
164+
165+ def test_bcc_many_method (self ):
166+ """Test bcc_many method"""
167+ bcc_recipients = [
168+ {"email" : "bcc1@example.com" , "name" : "BCC User 1" },
169+ {"email" : "bcc2@example.com" , "name" : "BCC User 2" },
170+ ]
171+
172+ email = (
173+ EmailBuilder ()
174+ .from_email ("sender@example.com" )
175+ .to ("recipient@example.com" )
176+ .bcc_many (bcc_recipients )
177+ .subject ("BCC Many Test" )
178+ .text ("Test message" )
179+ .build ()
180+ )
181+
182+ assert len (email .bcc ) == 2
183+ assert email .bcc [0 ].email == "bcc1@example.com"
184+ assert email .bcc [0 ].name == "BCC User 1"
185+ assert email .bcc [1 ].email == "bcc2@example.com"
186+ assert email .bcc [1 ].name == "BCC User 2"
187+
188+ def test_cc_bcc_mixed_usage (self ):
189+ """Test mixing single and array CC/BCC methods"""
190+ email = (
191+ EmailBuilder ()
192+ .from_email ("sender@example.com" )
193+ .to ("recipient@example.com" )
194+ .cc ("single-cc@example.com" , "Single CC" )
195+ .cc ([{"email" : "array-cc1@example.com" , "name" : "Array CC 1" }])
196+ .bcc ("single-bcc@example.com" )
197+ .bcc_many ([
198+ {"email" : "many-bcc1@example.com" , "name" : "Many BCC 1" },
199+ {"email" : "many-bcc2@example.com" }
200+ ])
201+ .subject ("Mixed Usage Test" )
202+ .text ("Test message" )
203+ .build ()
204+ )
205+
206+ assert len (email .cc ) == 2
207+ assert email .cc [0 ].email == "single-cc@example.com"
208+ assert email .cc [0 ].name == "Single CC"
209+ assert email .cc [1 ].email == "array-cc1@example.com"
210+ assert email .cc [1 ].name == "Array CC 1"
211+
212+ assert len (email .bcc ) == 3
213+ assert email .bcc [0 ].email == "single-bcc@example.com"
214+ assert email .bcc [0 ].name is None
215+ assert email .bcc [1 ].email == "many-bcc1@example.com"
216+ assert email .bcc [1 ].name == "Many BCC 1"
217+ assert email .bcc [2 ].email == "many-bcc2@example.com"
218+ assert email .bcc [2 ].name is None
219+
220+ def test_cc_bcc_invalid_input_validation (self ):
221+ """Test error handling for invalid CC/BCC input types"""
222+ builder = EmailBuilder ()
223+
224+ # Test invalid type for cc method
225+ with pytest .raises (ValidationError , match = "Email must be a string or list of recipient objects" ):
226+ builder .cc (123 ) # Invalid type
227+
228+ # Test invalid type for bcc method
229+ with pytest .raises (ValidationError , match = "Email must be a string or list of recipient objects" ):
230+ builder .bcc ({"email" : "test@example.com" }) # Dict instead of string or list
231+
90232 def test_content_methods (self ):
91233 """Test different content setting methods"""
92234 email = (
0 commit comments