Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/env python
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
import re
import requests
from selenium.webdriver.support.ui import WebDriverWait
from .. import BrowserID
from .. mocks.user import MockUser
import restmail
class BaseTest(object):
def browserid_url(self, base_url):
response = requests.get('%s/' % base_url, verify=False)
match = re.search(BrowserID.INCLUDE_URL_REGEX, response.content)
if match:
return match.group(1)
else:
raise Exception('Unable to determine BrowserID URL from %s.' % base_url)
def log_out(self, selenium, timeout):
WebDriverWait(selenium, timeout).until(
lambda s: s.find_element_by_id('loggedin').is_displayed())
selenium.find_element_by_css_selector('#loggedin a').click()
WebDriverWait(selenium, timeout).until(
lambda s: s.find_element_by_css_selector('#loggedout button').is_displayed())
def create_verified_user(self, selenium, timeout):
user = MockUser()
from .. pages.sign_in import SignIn
signin = SignIn(selenium, timeout, expect='new')
signin.sign_in_new_user(user.primary_email, user.password)
mail = restmail.get_mail(user.primary_email, timeout=timeout)
verify_url = re.search(BrowserID.VERIFY_URL_REGEX,
mail[0]['text']).group(0)
from .. pages.complete_registration import CompleteRegistration
complete_registration = CompleteRegistration(selenium,
timeout, verify_url,
expect='redirect')
return user