def test_send_mail_args(self, mail_mock): material = models.Material(slug='slug', author=self.user, body='mybody') material.save() response = self.client.post( '/' + str(material.id) + '/share/', {'name': 'test_name', 'to_email': '*****@*****.**', 'comment': 'comment'}, ) # # response = self.client.post( # '/' + str(material.id) + '/share/', # {'name': 'test_name', # 'to_email': '*****@*****.**', # 'comment': 'comment'}, # ) expected_body = views.TEMPLATE.format( title='', uri='http://testserver/2020/8/1/slug/', name='test_name', comment='comment', ) mail_mock.assert_called_with('test_name asks you to review next material: ', expected_body, '*****@*****.**', ['*****@*****.**']) # self.assertEqual(mail_mock.call_args_list[0][0][1], expected_body) mail_mock.assert_called_once()
def test_send_mail(self): mat = models.Material(slug='slug', author=self.user, body='mybody') mat.save() with mock.patch('lesson.views.send_mail') as mail_mock: response = self.client.post('/' + str(mat.id) + '/share/', {"name": "name", "my_email": "*****@*****.**", "to": "*****@*****.**", "comment": "adsfadsf"}) mail_mock.assert_called_once()
def test_send_mail_args(self, mail_mock): mat = models.Material(slug='slug', author=self.user, body='mybody') mat.save() response = self.client.post('/' + str(mat.id) + '/share/', {"name": "name", "my_email": "*****@*****.**", "to": "*****@*****.**", "comment": "adsfadsf"}) mail_mock.assert_called_once() mail_mock.assert_called_with()
def test_send_mail(self): material = models.Material(slug='slug', author=self.user, body='mybody') material.save() with mock.patch('lesson.views.send_mail') as mail_mock: response = self.client.post( '/'+str(material.id)+'/share/', {'name': 'test_name', 'to_email': '*****@*****.**', 'comment': 'comment'}, ) mail_mock.assert_called_once()
def test_send_mail_args(self, mail_mock): material = models.Material(slug='slug', author=self.user, body='mybody') material.save() with mock.patch('lesson.views.send_mail') as mail_mock: response = self.client.post( '/' + str(material.id) + '/share/', { "name": "test_name", "my_email": "*****@*****.**", "to_email": "*****@*****.**", "comment": "test comment", }) response = self.client.post( '/' + str(material.id) + '/share/', { "name": "test_name", "my_email": "*****@*****.**", "to_email": "*****@*****.**", "comment": "test comment", }) # mail_mock.assert_called_once() # mail_mock.assert_called_with('test_name ([email protected]) recommends you ', ' at http://testserver/2020/4/25/slug/\n\n test_name recommends you with comment:\n\ntest comment', '*****@*****.**', ['*****@*****.**']) self.assertEqual(mail_mock.call_args_list[0][0][2], "*****@*****.**")