2015-05-21 14:01:36 +03:00
|
|
|
# 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/.
|
|
|
|
|
2016-12-22 15:04:15 +03:00
|
|
|
import uuid
|
2017-12-08 14:48:29 +03:00
|
|
|
from urlparse import urlparse
|
2016-12-22 15:04:15 +03:00
|
|
|
|
2016-12-23 16:31:18 +03:00
|
|
|
import pytest
|
|
|
|
|
2016-12-22 15:04:15 +03:00
|
|
|
from tests import restmail
|
2015-05-21 14:01:36 +03:00
|
|
|
|
|
|
|
|
2015-11-04 15:54:24 +03:00
|
|
|
@pytest.fixture(scope='session')
|
2017-06-27 23:49:38 +03:00
|
|
|
def session_capabilities(pytestconfig, session_capabilities):
|
|
|
|
if pytestconfig.getoption('driver') == 'SauceLabs':
|
|
|
|
session_capabilities.setdefault('tags', []).append('mozillians')
|
2016-02-24 18:16:39 +03:00
|
|
|
return session_capabilities
|
2015-11-04 15:54:24 +03:00
|
|
|
|
|
|
|
|
2017-01-16 13:01:26 +03:00
|
|
|
@pytest.fixture
|
|
|
|
def capabilities(request, capabilities):
|
|
|
|
driver = request.config.getoption('driver')
|
|
|
|
if capabilities.get('browserName', driver).lower() == 'firefox':
|
|
|
|
capabilities['marionette'] = True
|
|
|
|
return capabilities
|
|
|
|
|
|
|
|
|
2015-05-21 14:01:36 +03:00
|
|
|
@pytest.fixture
|
2016-12-22 15:04:15 +03:00
|
|
|
def new_email():
|
|
|
|
return 'mozillians_{0}@restmail.net'.format(uuid.uuid1())
|
2015-05-21 14:01:36 +03:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture
|
2016-12-22 15:04:15 +03:00
|
|
|
def new_user(new_email):
|
|
|
|
return {'email': new_email}
|
2015-05-21 14:01:36 +03:00
|
|
|
|
|
|
|
|
2017-12-08 14:48:29 +03:00
|
|
|
@pytest.fixture(scope='session')
|
|
|
|
def stored_users(base_url, variables):
|
|
|
|
return variables[urlparse(base_url).hostname]['users']
|
2015-05-21 14:01:36 +03:00
|
|
|
|
|
|
|
|
2017-12-08 14:48:29 +03:00
|
|
|
@pytest.fixture(scope='function')
|
|
|
|
def vouched_user(request, stored_users):
|
|
|
|
slave_id = getattr(request.config, 'slaveinput', {}).get('slaveid', 'gw0')
|
|
|
|
return stored_users['vouched'][int(slave_id[2:])]
|
2015-05-21 14:01:36 +03:00
|
|
|
|
|
|
|
|
2017-12-08 14:48:29 +03:00
|
|
|
@pytest.fixture(scope='session')
|
2015-05-21 14:01:36 +03:00
|
|
|
def private_user(stored_users):
|
|
|
|
return stored_users['private']
|
2016-03-23 20:20:05 +03:00
|
|
|
|
|
|
|
|
2017-12-08 14:48:29 +03:00
|
|
|
@pytest.fixture(scope='session')
|
2016-03-23 20:20:05 +03:00
|
|
|
def unvouched_user(stored_users):
|
|
|
|
return stored_users['unvouched']
|
2016-12-22 15:04:15 +03:00
|
|
|
|
|
|
|
|
2018-02-07 16:13:33 +03:00
|
|
|
@pytest.fixture(scope='session')
|
|
|
|
def github_non_nda_user(stored_users):
|
|
|
|
return stored_users['github_non_nda']
|
|
|
|
|
|
|
|
|
2016-12-22 15:04:15 +03:00
|
|
|
@pytest.fixture
|
|
|
|
def login_link(username):
|
|
|
|
mail = restmail.get_mail(username)
|
|
|
|
mail_content = mail[0]['text'].replace('\n', ' ').replace('amp;', '').split(" ")
|
|
|
|
for link in mail_content:
|
2017-08-21 12:10:08 +03:00
|
|
|
if 'passwordless/verify_redirect' in link:
|
2016-12-22 15:04:15 +03:00
|
|
|
return link
|