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):
portal_type='Open Sale Order Line')
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')
def useWechatManually(self, web_site, user_id, is_email_expected=True):
......@@ -663,25 +668,19 @@ class DefaultScenarioMixin(TestSlapOSSecurityMixin):
self.assertNotEqual(person, None)
# User received an email for payment
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.')
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
# not enough for the number of objects on the site.
document_id = self.portal.portal_catalog.getResultValue(
portal_type="Payment Transaction",
simulation_state="started",
destination_section_uid=person.getUid()
).getId()
web_site.accounting_module[document_id].\
......@@ -689,21 +688,13 @@ class DefaultScenarioMixin(TestSlapOSSecurityMixin):
@changeSkin('RJS')
def usePayzenManually(self, web_site, user_id, is_email_expected=True):
person = self.portal.portal_catalog.getResultValue(
portal_type="Person",
user_id=user_id)
self.assertNotEqual(person, None)
# User received an email for payment
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.')
to_click_message = self.findMessage(person.getDefaultEmailText(),
'A new invoice has been generated')
if is_email_expected:
self.assertNotEqual(None, to_click_message)
......@@ -716,6 +707,7 @@ class DefaultScenarioMixin(TestSlapOSSecurityMixin):
document_id = self.portal.portal_catalog.getResultValue(
portal_type="Payment Transaction",
simulation_state="started",
destination_section_uid=person.getUid()
).getId()
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