Fakultas Ilmu Komputer UI

Commit 4a5697b4 authored by Izzan Fakhril Islam's avatar Izzan Fakhril Islam
Browse files

change from self to context on functional test

parent aa175c92
Pipeline #28557 failed with stages
in 13 minutes and 26 seconds
......@@ -11,40 +11,40 @@ SUBJECT = 'Your Login Link for Tutorial 7 PMPL'
class LoginTest(FunctionalTest):
def test_can_get_email_link_to_log_in(self):
selenium_host = self.get_host_from_selenium(self.host)
def test_can_get_email_link_to_log_in(context):
selenium_host = context.get_host_from_selenium(context.host)
email_form = selenium_host.find_element_by_name('email')
# A message appears telling her an email has been sent
self.wait_for(lambda: self.assertIn(
context.wait_for(lambda: context.assertIn(
"Check your email, you'll find a message with a link that will log you into the site.",
# She checks her email and finds a message
email = mail.outbox[0]
self.assertIn(TEST_EMAIL, email.to)
self.assertEqual(SUBJECT, email.subject)
context.assertIn(TEST_EMAIL, email.to)
context.assertEqual(SUBJECT, email.subject)
# It has a url link in it
self.assertIn('Use this link to log in', email.body)
context.assertIn('Use this link to log in', email.body)
url_search = re.search(r'http://.+/.+$', email.body)
if not url_search:
self.fail(f'Could not find url in email body:\n{email.body}')
context.fail(f'Could not find url in email body:\n{email.body}')
url = url_search.group(0)
self.assertIn(self.host, url)
context.assertIn(context.host, url)
# she clicks it
logged_in_account = self.get_host_from_selenium(url)
logged_in_account = context.get_host_from_selenium(url)
# she is logged in!
lambda: logged_in_account.find_element_by_link_text('Log out')
self.assertIn(TEST_EMAIL, selenium_host.find_element_by_tag_name('body').text)
context.assertIn(TEST_EMAIL, selenium_host.find_element_by_tag_name('body').text)
self.selenium.find_element_by_link_text('Log out').click()
context.selenium.find_element_by_link_text('Log out').click()
Supports Markdown
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