class TestEmailsService(TestCase): def setUp(self): self.es = Emails() def test_LIST(self, request_method): request_method.return_value = mock_response_result() self.es.list().all() self.assertEqual(request_method.call_args[0], ('get', _('user/emails'))) def test_ADD_without_emails(self, request_method): self.assertRaises(ValidationError, self.es.add) self.assertFalse(request_method.called) def test_ADD_with_emails(self, request_method): request_method.return_value = mock_response('post') self.es.add('*****@*****.**', '*****@*****.**') self.assertEqual(request_method.call_args[0], ('post', _('user/emails'))) @patch.object(Client, 'request') def test_ADD_filter_emails(self, client_request, dummy): client_request.return_value = mock_response('post') self.es.add('invalidemail.com', 'inva@[email protected]', '*****@*****.**') self.assertEqual(client_request.call_args[1], dict(data=('*****@*****.**', ))) def test_DELETE_with_emails(self, request_method): request_method.return_value = mock_response('delete') self.es.delete('email_must_be_founded') # or 404 raises self.assertEqual(request_method.call_args[0], ('delete', _('user/emails'))) def test_DELETE_without_emails(self, request_method): self.assertRaises(ValidationError, self.es.delete)
def setUp(self): self.es = Emails()