Exemplo n.º 1
0
 def notified_about_invalid_username_password(self, step: Step):
     """I should be notified about invalid username/password"""
     body = wait_for_element(step.context.browser,
                             'find_element_by_tag_name', 'body')
     from django.shortcuts import reverse
     current_url = str(step.context.browser.current_url)
     base_url = step.context.base_url
     assert_that(current_url, equal_to(base_url + reverse('account_login')))
     assert_that(
         body.text,
         contains_string("The username and/or "
                         "password you specified are not correct."))
Exemplo n.º 2
0
 def notified_about_duplicate_email(self, step):
     """I should be notified about duplicate email"""
     from django.shortcuts import reverse
     current_url = step.context.browser.current_url
     base_url = step.context.base_url
     assert_that(
         current_url, equal_to(base_url + reverse('account_signup')))
     body = wait_for_element(
         step.context.browser, 'find_element_by_tag_name', 'body')
     assert_that(
         body.text,
         contains_string("A user is already registered "
                         "with this e-mail address."))
Exemplo n.º 3
0
    def submit_valid_data(self, step):
        """I submit my data on sign up form"""
        base_url = step.context.base_url
        find_by_id = Chrome.find_element_by_id.__name__
        find_by_tag = Chrome.find_element_by_tag_name.__name__
        browser = step.context.browser
        username_input = wait_for_element(browser, find_by_id, 'id_username')
        email_input = wait_for_element(browser, find_by_id, 'id_email')
        password1_input = wait_for_element(browser, find_by_id, 'id_password1')
        password2_input = wait_for_element(browser, find_by_id, 'id_password2')
        button = wait_for_element(browser, find_by_tag, 'button')

        username_input.send_keys(step.context.user_data['username'])
        email_input.send_keys(step.context.user_data['email'])
        password1_input.send_keys(step.context.user_data['password'])
        password2_input.send_keys(step.context.user_data['password'])

        with patch('sys.stdout', new=StringIO()) as fake_out:
            button.submit()
            mail_content = fake_out.getvalue()
            step.context.confirm_url = mail_content[mail_content.find(
                base_url + '/accounts/confirm-email/'):].split()[0]
Exemplo n.º 4
0
 def notified_about_wrong_email(self, step):
     """I should be notified about it"""
     from django.shortcuts import reverse
     browser = step.context.browser
     base_url = step.context.base_url
     current_url = browser.current_url
     find_by_tag = Chrome.find_element_by_tag_name.__name__
     body = wait_for_element(browser, find_by_tag, 'body')
     assert_that(current_url,
                 equal_to(base_url + reverse('account_reset_password')))
     assert_that(
         body.text,
         contains_string("The e-mail address is not "
                         "assigned to any user account"))
Exemplo n.º 5
0
 def notified_about_invalid_password_link(self, step):
     """I will be notified about invalid reset password link"""
     browser = step.context.browser
     find_by_tag = Chrome.find_element_by_tag_name.__name__
     body = wait_for_element(browser, find_by_tag, 'body')
     assert_that(body.text, contains_string("Bad Token"))
Exemplo n.º 6
0
 def asked_to_confirm_email(self, step):
     """I should be asked to confirm my email"""
     find_by_tag = Chrome.find_element_by_tag_name.__name__
     body = wait_for_element(step.context.browser, find_by_tag, 'body')
     assert_that(body.text, contains_string('Verify Your E-mail Address'))
Exemplo n.º 7
0
 def get_confirmation_email(self, step):
     """I will receive a verification email"""
     assert_that(step.context.confirm_url, starts_with('http'))
     find_by_tag = Chrome.find_element_by_tag_name.__name__
     body = wait_for_element(step.context.browser, find_by_tag, 'body')
     assert_that(body.text, contains_string('Verify Your E-mail Address'))