-
Notifications
You must be signed in to change notification settings - Fork 194
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
577 additions
and
621 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
from herald.herald_server.tests.unittests.test_herald_base import TestHeraldBase | ||
from herald.herald_server.tests.unittests.test_herald_base import ( | ||
TestHeraldBase | ||
) | ||
from unittest.mock import patch | ||
|
||
|
||
|
@@ -9,65 +11,76 @@ def setUp(self, *args): | |
def test_email_send(self): | ||
email = ["[email protected]"] | ||
template_type = 'invite' | ||
template_params = {'message': "Email_message", | ||
'customer_id': "b2ed3073-8c48-417f-9275-eb0d6cc5c7f1", | ||
'object_name': "Object_name", 'object_type': "INFO", | ||
'level': "INFO"} | ||
template_params = { | ||
"message": "Email_message", | ||
"customer_id": "b2ed3073-8c48-417f-9275-eb0d6cc5c7f1", | ||
"object_name": "Object_name", | ||
"object_type": "INFO", | ||
"level": "INFO" | ||
} | ||
reply_to_email = '[email protected]' | ||
code, response = self.client_v2.email_send( | ||
email, "Email_subject", template_type, template_params, reply_to_email) | ||
email, "Email_subject", template_type, template_params, | ||
reply_to_email) | ||
result = { | ||
'email': email, | ||
'subject': 'Email_subject', | ||
'template_type': template_type, | ||
'template_params': template_params, | ||
'reply_to_email': reply_to_email | ||
"email": email, | ||
"subject": "Email_subject", | ||
"template_type": template_type, | ||
"template_params": template_params, | ||
"reply_to_email": reply_to_email | ||
} | ||
self.assertEqual(201, code) | ||
self.assertDictEqual(result, response) | ||
|
||
def test_email_hystax_registration_send(self): | ||
email = ["[email protected]"] | ||
template_type = 'new_employee' | ||
template_params = {'message': "Email_message", | ||
'customer_id': "b2ed3073-8c48-417f-9275-eb0d6cc5c7f1", | ||
'object_name': "Object_name", 'object_type': "INFO", | ||
'level': "INFO", 'texts': {'user_email': '[email protected]'}} | ||
template_params = { | ||
"message": "Email_message", | ||
"customer_id": "b2ed3073-8c48-417f-9275-eb0d6cc5c7f1", | ||
"object_name": "Object_name", | ||
"object_type": "INFO", | ||
"level": "INFO", | ||
"texts": {"user_email": "[email protected]"} | ||
} | ||
publish_message_p_configured = patch( | ||
'herald.herald_server.controllers.email.EmailController.publish_message' | ||
).start() | ||
"herald.herald_server.controllers.email." | ||
"EmailController.publish_message").start() | ||
code, response = self.client_v2.email_send( | ||
email, "Email_subject", template_type, template_params) | ||
self.assertEqual(publish_message_p_configured.called, True) | ||
result = { | ||
'email': ["[email protected]"], | ||
'subject': 'Email_subject', | ||
'template_type': template_type, | ||
'template_params': template_params, | ||
'reply_to_email': None | ||
"email": ["[email protected]"], | ||
"subject": "Email_subject", | ||
"template_type": template_type, | ||
"template_params": template_params, | ||
"reply_to_email": None | ||
} | ||
self.assertEqual(201, code) | ||
self.assertDictEqual(result, response) | ||
|
||
def test_email_hystax_registration_not_publish(self): | ||
email = ["[email protected]"] | ||
template_type = 'new_employee' | ||
template_params = {'message': "Email_message", | ||
'customer_id': "b2ed3073-8c48-417f-9275-eb0d6cc5c7f1", | ||
'object_name': "Object_name", 'object_type': "INFO", | ||
'level': "INFO", 'texts': {'user_email': '[email protected]'}} | ||
template_params = { | ||
"message": "Email_message", | ||
"customer_id": "b2ed3073-8c48-417f-9275-eb0d6cc5c7f1", | ||
"object_name": "Object_name", | ||
"object_type": "INFO", | ||
"level": "INFO", | ||
"texts": {"user_email": "[email protected]"}} | ||
publish_message_p_configured = patch( | ||
'herald.herald_server.controllers.email.EmailController.publish_message' | ||
).start() | ||
"herald.herald_server.controllers.email." | ||
"EmailController.publish_message").start() | ||
code, response = self.client_v2.email_send( | ||
email, "Email_subject", template_type, template_params) | ||
self.assertEqual(publish_message_p_configured.called, False) | ||
result = { | ||
'email': ["[email protected]"], | ||
'subject': 'Email_subject', | ||
'template_type': template_type, | ||
'template_params': template_params, | ||
'reply_to_email': None | ||
"email": ["[email protected]"], | ||
"subject": "Email_subject", | ||
"template_type": template_type, | ||
"template_params": template_params, | ||
"reply_to_email": None | ||
} | ||
self.assertEqual(201, code) | ||
self.assertDictEqual(result, response) | ||
|
@@ -106,4 +119,35 @@ def test_validation_email_payload(self): | |
email=[valid_email], subject='subj', | ||
template_params=invalid_template_params) | ||
self.assertEqual(400, code) | ||
self.assertEqual('invalid template_params', response['error']['reason']) | ||
self.assertEqual('invalid template_params', | ||
response['error']['reason']) | ||
|
||
def test_email_template_params(self): | ||
valid_email = '[email protected]' | ||
template_type = 'new_employee' | ||
subject = 'subj' | ||
code, response = self.client_v2.email_send( | ||
email=[valid_email], subject=subject, | ||
template_type=template_type, template_params=None) | ||
self.assertEqual(201, code) | ||
result = { | ||
"email": [valid_email], | ||
"subject": subject, | ||
"template_type": template_type, | ||
"template_params": None, | ||
"reply_to_email": None | ||
} | ||
self.assertDictEqual(result, response) | ||
|
||
code, response = self.client_v2.email_send( | ||
email=[valid_email], subject=subject, | ||
template_type=template_type, template_params={}) | ||
self.assertEqual(201, code) | ||
result = { | ||
"email": [valid_email], | ||
"subject": subject, | ||
"template_type": template_type, | ||
"template_params": {}, | ||
"reply_to_email": None | ||
} | ||
self.assertDictEqual(result, response) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.