Commit 131cd004 authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_cloud: Attempt to reduce flakiness

   It ensure that selected payment is from the proper user.
parent ca466637
...@@ -654,6 +654,11 @@ class DefaultScenarioMixin(TestSlapOSSecurityMixin): ...@@ -654,6 +654,11 @@ class DefaultScenarioMixin(TestSlapOSSecurityMixin):
portal_type='Open Sale Order Line') portal_type='Open Sale Order Line')
self.assertEqual(len(line_list), 0) self.assertEqual(len(line_list), 0)
def findMessage(self, email, body):
for candidate in reversed(self.portal.MailHost.getMessageList()):
if [q for q in candidate[1] if email in q] and body in candidate[2]:
return candidate[2]
@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):
...@@ -663,25 +668,19 @@ class DefaultScenarioMixin(TestSlapOSSecurityMixin): ...@@ -663,25 +668,19 @@ class DefaultScenarioMixin(TestSlapOSSecurityMixin):
self.assertNotEqual(person, None) self.assertNotEqual(person, None)
# User received an email for payment to_click_message = self.findMessage(person.getDefaultEmailText(),
email = person.getDefaultEmailText() 'A new invoice has been generated')
def findMessage(email, body):
for candidate in reversed(self.portal.MailHost.getMessageList()):
if [q for q in candidate[1] if email in q] and body in candidate[2]:
return candidate[2]
to_click_message = findMessage(email, 'A new invoice has been generated.')
if is_email_expected: if is_email_expected:
self.assertNotEqual(None, to_click_message) self.assertNotEqual(None, to_click_message)
else: else:
self.assertEqual(None, to_click_message) 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.
document_id = self.portal.portal_catalog.getResultValue( document_id = self.portal.portal_catalog.getResultValue(
portal_type="Payment Transaction", portal_type="Payment Transaction",
simulation_state="started", simulation_state="started",
destination_section_uid=person.getUid()
).getId() ).getId()
web_site.accounting_module[document_id].\ web_site.accounting_module[document_id].\
...@@ -689,21 +688,13 @@ class DefaultScenarioMixin(TestSlapOSSecurityMixin): ...@@ -689,21 +688,13 @@ class DefaultScenarioMixin(TestSlapOSSecurityMixin):
@changeSkin('RJS') @changeSkin('RJS')
def usePayzenManually(self, web_site, user_id, is_email_expected=True): def usePayzenManually(self, web_site, user_id, is_email_expected=True):
person = self.portal.portal_catalog.getResultValue( person = self.portal.portal_catalog.getResultValue(
portal_type="Person", portal_type="Person",
user_id=user_id) user_id=user_id)
self.assertNotEqual(person, None) self.assertNotEqual(person, None)
to_click_message = self.findMessage(person.getDefaultEmailText(),
# User received an email for payment 'A new invoice has been generated')
email = person.getDefaultEmailText()
def findMessage(email, body):
for candidate in reversed(self.portal.MailHost.getMessageList()):
if [q for q in candidate[1] if email in q] and body in candidate[2]:
return candidate[2]
to_click_message = findMessage(email, 'A new invoice has been generated.')
if is_email_expected: if is_email_expected:
self.assertNotEqual(None, to_click_message) self.assertNotEqual(None, to_click_message)
...@@ -716,6 +707,7 @@ class DefaultScenarioMixin(TestSlapOSSecurityMixin): ...@@ -716,6 +707,7 @@ class DefaultScenarioMixin(TestSlapOSSecurityMixin):
document_id = self.portal.portal_catalog.getResultValue( document_id = self.portal.portal_catalog.getResultValue(
portal_type="Payment Transaction", portal_type="Payment Transaction",
simulation_state="started", simulation_state="started",
destination_section_uid=person.getUid()
).getId() ).getId()
web_site.accounting_module[document_id].\ web_site.accounting_module[document_id].\
......
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