@@ -234,7 +234,11 @@ def test_it_creates_a_proper_sendable_message(self, client):
234234235235236236 bcc = []
237- sendable = client ._make_sendable_message (subject , content , to , cc , bcc )
237+ references = []
238+ in_reply_to = []
239+ sendable = client ._make_sendable_message (
240+ subject , content , to , cc , bcc , references , in_reply_to
241+ )
238242 decoded = base64 .urlsafe_b64decode (sendable ["raw" ]).decode ("utf-8" )
239243 assert decoded .startswith ("Content-Type: text/html;" )
240244 assert f"subject: { subject } \n " in decoded
@@ -257,8 +261,9 @@ def test_it_send_and_return_a_raw_message(self, mocker, raw_complete_message):
257261258262 body = {
259263 "raw" : base64 .urlsafe_b64encode (
260- b'Content-Type: text/html; charset="us-ascii"\n MIME-Version: 1.0\n Content-Transfer-Encoding: 7bit\n subject: Hi there!\n from: [email protected] \n to: [email protected] \n cc: \n bcc: \n \n <html><p>Hey</p></html>' 261- ).decode ("utf-8" )
264+ b'Content-Type: text/html; charset="us-ascii"\n MIME-Version: 1.0\n Content-Transfer-Encoding: 7bit\n subject: Hi there!\n from: [email protected] \n to: [email protected] \n cc: \n bcc: \n references: \n in-reply-to: \n \n <html><p>Hey</p></html>' 265+ ).decode ("utf-8" ),
266+ "threadId" : None ,
262267 },
263268 )
264269
@@ -275,7 +280,43 @@ def test_it_returns_the_sent_message(self, client, mocker, raw_complete_message)
275280276281 )
277282 mocked_send_raw_message .assert_called_once_with (
278- "Hi there!" ,
"<html><p>Hey</p></html>" ,
"[email protected] " ,
None ,
None 283+ "Hi there!" ,
284+ "<html><p>Hey</p></html>" ,
285+ 286+ None ,
287+ None ,
288+ None ,
289+ None ,
290+ None ,
279291 )
280292 assert isinstance (sent_message , Message )
281293 assert sent_message .id == raw_complete_message ["id" ]
294+
295+
296+ class TestReply :
297+ def test_it_returns_the_sent_message (self , client , mocker , raw_complete_message ):
298+ message_to_reply = Message (client , raw_complete_message )
299+ expected_message_to_be_sent = {"id" : "114ADC" , "internalDate" : "1566398665" }
300+ mocked_send_raw_message = mocker .patch (
301+ "gmail_wrapper.client.GmailClient.send_raw" ,
302+ return_value = expected_message_to_be_sent ,
303+ )
304+ sent_message = message_to_reply .reply (
305+ "The quick brown fox jumps over the lazy dog"
306+ )
307+ mocked_send_raw_message .assert_called_once_with (
308+ "Re:Urgent errand" ,
309+ "The quick brown fox jumps over the lazy dog" ,
310+ 311+ None ,
312+ None ,
313+ [
314+ "<BY5PR15MB353717D866FC27FEE4DB4EC7F77E0@BY5PR15MB3537.namprd15.prod.outlook.com>"
315+ ],
316+ [
317+ "<BY5PR15MB353717D866FC27FEE4DB4EC7F77E0@BY5PR15MB3537.namprd15.prod.outlook.com>"
318+ ],
319+ "AA121212" ,
320+ )
321+ assert isinstance (sent_message , Message )
322+ assert sent_message .id == expected_message_to_be_sent ["id" ]
0 commit comments