Commit 431ff687 authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_cloud: Make assertion of the message more flexible when assert it

   This allow us to translate and re-run the tests with real notification messages.
parent 131cd004
...@@ -659,6 +659,20 @@ class DefaultScenarioMixin(TestSlapOSSecurityMixin): ...@@ -659,6 +659,20 @@ class DefaultScenarioMixin(TestSlapOSSecurityMixin):
if [q for q in candidate[1] if email in q] and body in candidate[2]: if [q for q in candidate[1] if email in q] and body in candidate[2]:
return candidate[2] return candidate[2]
def assertInvoiceNotification(self, person, is_email_expected=True):
if person.getLanguage() == "zh":
expected_message = self.expected_invoice_zh_notification_message
else:
expected_message = self.expected_invoice_en_notification_message
to_click_message = self.findMessage(person.getDefaultEmailText(),
expected_message)
if is_email_expected:
self.assertNotEqual(None, to_click_message)
else:
self.assertEqual(None, to_click_message)
@changeSkin('RJS') @changeSkin('RJS')
def useWechatManually(self, web_site, user_id, is_email_expected=True): def useWechatManually(self, web_site, user_id, is_email_expected=True):
...@@ -667,13 +681,7 @@ class DefaultScenarioMixin(TestSlapOSSecurityMixin): ...@@ -667,13 +681,7 @@ class DefaultScenarioMixin(TestSlapOSSecurityMixin):
user_id=user_id) user_id=user_id)
self.assertNotEqual(person, None) self.assertNotEqual(person, None)
self.assertInvoiceNotification(person, is_email_expected)
to_click_message = self.findMessage(person.getDefaultEmailText(),
'A new invoice has been generated')
if is_email_expected:
self.assertNotEqual(None, to_click_message)
else:
self.assertEqual(None, to_click_message)
# If you are using live test, be aware that the call of the alarm can be # If you are using live test, be aware that the call of the alarm can be
# not enough for the number of objects on the site. # not enough for the number of objects on the site.
...@@ -693,13 +701,7 @@ class DefaultScenarioMixin(TestSlapOSSecurityMixin): ...@@ -693,13 +701,7 @@ class DefaultScenarioMixin(TestSlapOSSecurityMixin):
user_id=user_id) user_id=user_id)
self.assertNotEqual(person, None) self.assertNotEqual(person, None)
to_click_message = self.findMessage(person.getDefaultEmailText(), self.assertInvoiceNotification(person, is_email_expected)
'A new invoice has been generated')
if is_email_expected:
self.assertNotEqual(None, to_click_message)
else:
self.assertEqual(None, to_click_message)
# Pay to payzen... # Pay to payzen...
# If you are using live test, be aware that the call of the alarm can be # If you are using live test, be aware that the call of the alarm can be
......
...@@ -80,6 +80,12 @@ def withAbort(func): ...@@ -80,6 +80,12 @@ def withAbort(func):
class SlapOSTestCaseMixin(testSlapOSMixin): class SlapOSTestCaseMixin(testSlapOSMixin):
# Define few expected defaults
expected_invoice_en_notification_message = 'A new invoice has been generated'
# W/o notification messages the default is send message in english
expected_invoice_zh_notification_message = 'A new invoice has been generated'
def afterSetUp(self): def afterSetUp(self):
testSlapOSMixin.afterSetUp(self) testSlapOSMixin.afterSetUp(self)
self.changeSkin('View') self.changeSkin('View')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment