Switch to using pytest-variables for user and API credentials. Fixes #166

This commit is contained in:
Dave Hunt 2015-05-21 10:00:43 +01:00
Родитель a9bee504a6
Коммит c5d3eb1f8a
19 изменённых файлов: 191 добавлений и 234 удалений

Просмотреть файл

@ -98,15 +98,15 @@ WebDriver does not need a Selenium Server or Grid to run so these examples bypas
An example of running all tests without a Selenium Server:
py.test --driver=firefox --credentials=/path/to/credentials/credentials.yaml --destructive .
py.test --driver=firefox --variables=/path/to/variables.json --destructive .
An example of running all of the tests in one file:
py.test --driver=firefox --credentials=/path/to/credentials/credentials.yaml tests/test_manage_runs_page.py
py.test --driver=firefox --variables=/path/to/variables.json tests/test_manage_runs_page.py
An example of running one test in a file:
py.test --driver=firefox --credentials=/path/to/credentials/credentials.yaml tests/test_manage_runs_page.py -k test_that_user_can_create_and_delete_run
py.test --driver=firefox --variables=/path/to/variables.json tests/test_manage_runs_page.py -k test_that_user_can_create_and_delete_run
The mozwebqa plugin has advanced command line options for reporting and using browsers. See the documentation on [pytest mozwebqa github][pymozwebqa].
[pymozwebqa]: https://github.com/mozilla/pytest-mozwebqa

Просмотреть файл

@ -1,5 +1,3 @@
#!/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/.
@ -11,46 +9,52 @@ from mocks.mock_element import MockElement
from mocks.moztrap_api import MoztrapAPI
@pytest.fixture
def stored_users(variables):
return variables['users']
@pytest.fixture
def existing_user(stored_users):
return stored_users['default']
@pytest.fixture(scope='function')
def mozwebqa_logged_in(request):
def login(request, mozwebqa, existing_user):
from pages.login_page import MozTrapLoginPage
mozwebqa = request.getfuncargvalue('mozwebqa')
login_pg = MozTrapLoginPage(mozwebqa)
login_pg.go_to_login_page()
login_pg.login()
login_pg.login(existing_user['email'], existing_user['password'])
return mozwebqa
@pytest.fixture
def api(request, variables):
url = request.getfuncargvalue('mozwebqa').base_url
return MoztrapAPI(variables['api']['user'], variables['api']['key'], url)
@pytest.fixture(scope='function')
def product(request):
"""Return a product created via the Moztrap API, and automatically delete the product after the test."""
mozwebqa = request.getfuncargvalue('mozwebqa')
credentials = mozwebqa.credentials['default']
request.product = MockProduct()
api = MoztrapAPI(credentials['api_user'], credentials['api_key'], mozwebqa.base_url)
api.create_product(request.product)
def product(request, api):
"""Return a product created via the API."""
product = MockProduct()
api.create_product(product)
# This acts like a tearDown, running after each test function
def fin():
if hasattr(request, 'product'):
api.delete_product(request.product)
# We have to add this here, rather than in a finalizer for the element fixture as the
# Product has to be deleted first
if hasattr(request, 'element'):
api.delete_element(request.element)
if not product.get('deleted', False):
api.delete_product(product)
request.addfinalizer(fin)
return request.product
return product
@pytest.fixture(scope='function')
def element(request):
"""Return an element with an embedded category created via the Moztrap API,
and automatically delete them after the test."""
mozwebqa = request.getfuncargvalue('mozwebqa')
credentials = mozwebqa.credentials['default']
request.element = MockElement()
api = MoztrapAPI(credentials['api_user'], credentials['api_key'], mozwebqa.base_url)
api.create_element(request.element)
def element(request, api, product):
"""Return an element with an embedded category created via the API."""
element = MockElement()
api.create_element(element)
return request.element
def fin():
api.delete_product(product)
product['deleted'] = True
api.delete_element(element)
request.addfinalizer(fin)
return element

Просмотреть файл

@ -1,39 +0,0 @@
# 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/.
# File contains users data.
#
# Each user is a section named with its role
# and any number of values. At least email,
# password and name should be present.
#
# Example:
# admin:
# username: username
# password: password
# name: Test User
#
# Still, you are free to add any more data you wish. It will be kept
# in the same dictionary.
#
# Example:
# admin:
# username: username
# password: password
# name: Test User
# email: email@site.com
# some_user_data: data
#
# The contents of this file are accessible via the pytest-mozwebqa plugin:
#
# Example:
# credentials = mozwebqa.credentials['default']
# credentials['username']
default:
email: <value>
password: <value>
name: <value>
api_user: webqa_api_user
api_key: a0c050d8-84c8-49f5-963f-97eae922bc48

Просмотреть файл

@ -48,7 +48,7 @@ class MoztrapAPI:
params=self.params,
headers=self.headers)
response.raise_for_status()
if response.status_code == 200:
if response.status_code == requests.codes.ok:
return True
else:
print "Failed to delete resource: %s with %s.\n%s" % (

Просмотреть файл

@ -50,7 +50,7 @@ class MozTrapBasePage(Page):
def toggle_drilldown(self):
self.selenium.find_element(*self._drilldown_locator).click()
def click_login(self, user='default'):
def login(self, email, password):
self.find_element(*self._signin_locator).click()
from pages.login_page import MozTrapLoginPage
MozTrapLoginPage(self.testsetup).login(user)
MozTrapLoginPage(self.testsetup).login(email, password)

Просмотреть файл

@ -20,7 +20,6 @@ from pages.manage_profiles_page import MozTrapManageProfilesPage
from pages.create_bulk_cases_page import MozTrapCreateBulkCasesPage
from mocks.mock_suite import MockSuite
from mocks.mock_case import MockCase
from mocks.moztrap_api import MoztrapAPI
class BaseTest(object):
@ -88,19 +87,15 @@ class BaseTest(object):
if delete_version:
self.delete_version(mozwebqa, version=run['version'])
def create_suite(self, mozwebqa, product, use_API, status='active', case_list=[], **kwargs):
if use_API:
credentials = mozwebqa.credentials['default']
def create_suite(self, mozwebqa, product, api=None, status='active', case_list=[], **kwargs):
if api is not None:
suite = MockSuite()
api = MoztrapAPI(credentials['api_user'], credentials['api_key'], mozwebqa.base_url)
api.create_suite(suite, product, case_list)
else:
create_suite_pg = MozTrapCreateSuitePage(mozwebqa)
create_suite_pg.go_to_create_suite_page()
suite = create_suite_pg.create_suite(product=product['name'], status=status, case_list=case_list, **kwargs)
suite['product'] = product
return suite
def delete_suite(self, mozwebqa, suite):
@ -110,11 +105,9 @@ class BaseTest(object):
manage_suites_pg.filter_form.filter_by(lookup='name', value=suite['name'])
manage_suites_pg.delete_suite(name=suite['name'])
def create_case(self, mozwebqa, product, use_API, mock_case=None):
if use_API:
credentials = mozwebqa.credentials['default']
def create_case(self, mozwebqa, product, api=None, mock_case=None):
if api is not None:
case = MockCase()
api = MoztrapAPI(credentials['api_user'], credentials['api_key'], mozwebqa.base_url)
api.create_case(case, product)
else:
mock_case = mock_case or MockCase()
@ -152,12 +145,12 @@ class BaseTest(object):
create_profile_pg.go_to_create_profile_page()
create_profile_pg.delete_environment_category(category_name=profile['category'])
def create_and_run_test(self, mozwebqa, product, element):
def create_and_run_test(self, api, mozwebqa, product, element):
home_pg = MozTrapHomePage(mozwebqa)
self.connect_product_to_element(mozwebqa, product, element)
case = self.create_case(mozwebqa, product, use_API=True)
suite = self.create_suite(mozwebqa, product=product, use_API=True, case_list=[case])
case = self.create_case(mozwebqa, product, api=api)
suite = self.create_suite(mozwebqa, product=product, api=api, case_list=[case])
run = self.create_run(mozwebqa, activate=True, product=product, version=product['version'], suite_name_list=[suite['name']])
home_pg.go_to_home_page()
@ -165,11 +158,9 @@ class BaseTest(object):
return case, suite, run
def create_bulk_cases(self, mozwebqa, product, use_API, cases_amount=2, status='active', version=None, suite_name=None, **kwargs):
if use_API:
def create_bulk_cases(self, mozwebqa, product, api=None, cases_amount=2, status='active', version=None, suite_name=None, **kwargs):
if api is not None:
cases = []
credentials = mozwebqa.credentials['default']
api = MoztrapAPI(credentials['api_user'], credentials['api_key'], mozwebqa.base_url)
for i in xrange(cases_amount):
case = MockCase()
if 'name' in kwargs:

Просмотреть файл

@ -25,19 +25,14 @@ class MozTrapLoginPage(MozTrapBasePage):
self.maximize_window()
self.is_the_current_page
def login(self, user='default'):
def login(self, email, password):
from home_page import MozTrapHomePage
if isinstance(user, str):
user = self.testsetup.credentials[user]
from browserid import BrowserID
self.selenium.find_element(*self._browserid_locator).click()
browser_id = BrowserID(self.selenium, timeout=self.timeout)
browser_id.sign_in(user['email'], user['password'])
WebDriverWait(self.selenium, self.timeout).until(lambda s: self.header.is_user_logged_in)
browser_id.sign_in(email, password)
WebDriverWait(self.selenium, self.timeout).until(
lambda s: self.header.is_user_logged_in)
return MozTrapHomePage(self.testsetup)
@property

Просмотреть файл

@ -1,7 +1,6 @@
# This pulls in all the libraries needed to run Selenium tests
# on the Mozilla MozTrap project
PyYAML==3.10
UnittestZero
certifi==0.0.8
chardet==1.0.1
@ -9,6 +8,7 @@ execnet==1.1
py==1.4.26
pytest==2.7.0
pytest-mozwebqa
pytest-variables
requests==2.4.3
selenium
-e git+https://github.com/mozilla/bidpom.git@master#egg=browserid

Просмотреть файл

@ -16,32 +16,26 @@ class TestHomepage(BaseTest):
@pytest.mark.moztrap([3385, 3386])
@pytest.mark.nondestructive
def test_that_user_can_login_and_logout(self, mozwebqa):
def test_that_user_can_login_and_logout(self, mozwebqa, existing_user):
from pages.login_page import MozTrapLoginPage
login_pg = MozTrapLoginPage(mozwebqa)
home_pg = MozTrapHomePage(mozwebqa)
home_pg.get_relative_path('/')
Assert.false(home_pg.header.is_user_logged_in)
login_pg.go_to_login_page()
login_pg.login()
user = home_pg.testsetup.credentials['default']
users_name = user['name']
login_pg.login(existing_user['email'], existing_user['password'])
Assert.true(home_pg.header.is_user_logged_in)
Assert.equal(home_pg.header.username_text, users_name)
Assert.equal(home_pg.header.username_text, existing_user['name'])
home_pg.header.click_logout()
home_pg.get_relative_path('/')
Assert.false(home_pg.header.is_user_logged_in)
@pytest.mark.moztrap(3387)
def test_that_user_can_select_product(self, mozwebqa_logged_in, product):
home_pg = MozTrapHomePage(mozwebqa_logged_in)
def test_that_user_can_select_product(self, mozwebqa, login, product):
home_pg = MozTrapHomePage(mozwebqa)
home_pg.go_to_home_page()
@ -52,10 +46,10 @@ class TestHomepage(BaseTest):
Assert.true(home_pg.is_product_version_visible(product))
@pytest.mark.moztrap(3388)
def test_that_user_can_select_version(self, mozwebqa_logged_in, product):
home_pg = MozTrapHomePage(mozwebqa_logged_in)
def test_that_user_can_select_version(self, mozwebqa, login, product):
home_pg = MozTrapHomePage(mozwebqa)
run = self.create_run(mozwebqa_logged_in, product=product, activate=True)
run = self.create_run(mozwebqa, product=product, activate=True)
home_pg.go_to_home_page()
home_pg.select_item(run['version']['product']['name'])
@ -67,10 +61,10 @@ class TestHomepage(BaseTest):
Assert.true(home_pg.is_element_visible(*run['homepage_locator']))
@pytest.mark.moztrap(3414)
def test_that_user_can_select_run(self, mozwebqa_logged_in, product):
home_pg = MozTrapHomePage(mozwebqa_logged_in)
def test_that_user_can_select_run(self, mozwebqa, login, product):
home_pg = MozTrapHomePage(mozwebqa)
run = self.create_run(mozwebqa_logged_in, product=product, activate=True)
run = self.create_run(mozwebqa, product=product, activate=True)
home_pg.go_to_home_page()
home_pg.select_item(run['version']['product']['name'])

Просмотреть файл

@ -16,10 +16,10 @@ from pages.manage_cases_page import MozTrapManageCasesPage
class TestManageCasesPage(BaseTest):
@pytest.mark.moztrap([142, 137])
def test_that_user_can_create_and_delete_case(self, mozwebqa_logged_in, product):
manage_cases_pg = MozTrapManageCasesPage(mozwebqa_logged_in)
def test_that_user_can_create_and_delete_case(self, mozwebqa, login, product):
manage_cases_pg = MozTrapManageCasesPage(mozwebqa)
case = self.create_case(mozwebqa_logged_in, product, use_API=False)
case = self.create_case(mozwebqa, product)
manage_cases_pg.filter_form.filter_by(lookup='name', value=case['name'])
@ -29,16 +29,16 @@ class TestManageCasesPage(BaseTest):
Assert.false(manage_cases_pg.is_element_present(*case['locator']))
def test_that_deleting_single_version_of_case_does_not_delete_all_versions(self, mozwebqa_logged_in, product):
def test_that_deleting_single_version_of_case_does_not_delete_all_versions(self, api, mozwebqa, login, product):
# prerequisites
test_case = self.create_case(mozwebqa_logged_in, product=product, use_API=True)
test_case = self.create_case(mozwebqa, product=product, api=api)
first_version = product['version']
second_version = self.create_version(mozwebqa_logged_in, product=product)
second_version = self.create_version(mozwebqa, product=product)
product_versions = [u'%s %s' % (product['name'], version['name'])
for version in (first_version, second_version)]
manage_cases_pg = MozTrapManageCasesPage(mozwebqa_logged_in)
manage_cases_pg = MozTrapManageCasesPage(mozwebqa)
manage_cases_pg.go_to_manage_cases_page()
filter_item = manage_cases_pg.filter_form.filter_by(lookup='product', value=product['name'])
test_cases = manage_cases_pg.test_cases
@ -57,15 +57,15 @@ class TestManageCasesPage(BaseTest):
Assert.equal(test_cases[0].name, test_case['name'], u'that\'s wrong test case')
Assert.equal(test_cases[0].product_version, product_versions[0], u'that\'s wrong product version')
def test_that_manage_cases_list_shows_all_case_versions_individually(self, mozwebqa_logged_in, product):
def test_that_manage_cases_list_shows_all_case_versions_individually(self, api, mozwebqa, login, product):
# prerequisites
test_case = self.create_case(mozwebqa_logged_in, product=product, use_API=True)
test_case = self.create_case(mozwebqa, product=product, api=api)
first_version = product['version']
second_version = self.create_version(mozwebqa_logged_in, product=product)
second_version = self.create_version(mozwebqa, product=product)
product_versions = [u'%s %s' % (product['name'], version['name'])
for version in (first_version, second_version)]
manage_cases_pg = MozTrapManageCasesPage(mozwebqa_logged_in)
manage_cases_pg = MozTrapManageCasesPage(mozwebqa)
manage_cases_pg.go_to_manage_cases_page()
manage_cases_pg.filter_form.filter_by(lookup='name', value=test_case['name'])
filtered_cases = manage_cases_pg.test_cases
@ -79,13 +79,12 @@ class TestManageCasesPage(BaseTest):
sorted([case.product_version for case in filtered_cases]),
u'expected product versions of test cases don\'t match actual ones')
def test_that_creates_tag_during_test_case_creation(self, mozwebqa_logged_in, product):
def test_that_creates_tag_during_test_case_creation(self, mozwebqa, login, product):
mock_tag = MockTag()
mock_case = MockCase(tag=mock_tag)
test_case = self.create_case(mozwebqa_logged_in, product=product,
use_API=False, mock_case=mock_case)
test_case = self.create_case(mozwebqa, product=product, mock_case=mock_case)
manage_cases_pg = MozTrapManageCasesPage(mozwebqa_logged_in)
manage_cases_pg = MozTrapManageCasesPage(mozwebqa)
manage_cases_pg.filter_form.filter_by(lookup='name', value=test_case['name'])
filtered_cases = manage_cases_pg.test_cases

Просмотреть файл

@ -14,10 +14,10 @@ from pages.manage_products_page import MozTrapManageProductsPage
class TestManageProductsPage(BaseTest):
@pytest.mark.moztrap([145, 146])
def test_that_user_can_create_and_delete_product(self, mozwebqa_logged_in):
manage_products_pg = MozTrapManageProductsPage(mozwebqa_logged_in)
def test_that_user_can_create_and_delete_product(self, mozwebqa, login):
manage_products_pg = MozTrapManageProductsPage(mozwebqa)
product = self.create_product(mozwebqa_logged_in)
product = self.create_product(mozwebqa)
manage_products_pg.filter_form.filter_by(lookup='name', value=product['name'])
@ -28,8 +28,8 @@ class TestManageProductsPage(BaseTest):
Assert.false(manage_products_pg.is_element_present(*product['locator']))
@pytest.mark.moztrap(151)
def test_that_user_can_filter_product_by_name(self, mozwebqa_logged_in, product):
manage_products_pg = MozTrapManageProductsPage(mozwebqa_logged_in)
def test_that_user_can_filter_product_by_name(self, mozwebqa, login, product):
manage_products_pg = MozTrapManageProductsPage(mozwebqa)
manage_products_pg.go_to_manage_products_page()
filter_item = manage_products_pg.filter_form.filter_by(lookup='name', value='Another Product')
@ -42,8 +42,8 @@ class TestManageProductsPage(BaseTest):
Assert.true(manage_products_pg.is_product_present(product))
@pytest.mark.moztrap(3415)
def test_that_user_can_filter_product_by_name_without_mouse(self, mozwebqa_logged_in, product):
manage_products_pg = MozTrapManageProductsPage(mozwebqa_logged_in)
def test_that_user_can_filter_product_by_name_without_mouse(self, mozwebqa, login, product):
manage_products_pg = MozTrapManageProductsPage(mozwebqa)
manage_products_pg.go_to_manage_products_page()
filter_item = manage_products_pg.filter_form.filter_without_mouse_by(lookup='name', value='Another Product')

Просмотреть файл

@ -14,12 +14,12 @@ from pages.manage_profiles_page import MozTrapManageProfilesPage
class TestManageProfilesPage(BaseTest):
@pytest.mark.moztrap([154, 155])
def test_that_user_can_create_and_delete_profile(self, mozwebqa_logged_in):
def test_that_user_can_create_and_delete_profile(self, mozwebqa, login):
from pages.create_profile_page import MozTrapCreateProfilePage
manage_profiles_pg = MozTrapManageProfilesPage(mozwebqa_logged_in)
create_profile_pg = MozTrapCreateProfilePage(mozwebqa_logged_in)
manage_profiles_pg = MozTrapManageProfilesPage(mozwebqa)
create_profile_pg = MozTrapCreateProfilePage(mozwebqa)
profile = self.create_profile(mozwebqa_logged_in)
profile = self.create_profile(mozwebqa)
manage_profiles_pg.filter_form.filter_by(lookup='name', value=profile['name'])

Просмотреть файл

@ -14,10 +14,10 @@ from pages.manage_runs_page import MozTrapManageRunsPage
class TestManageRunsPage(BaseTest):
@pytest.mark.moztrap([113, 112])
def test_that_user_can_create_and_delete_run(self, mozwebqa_logged_in, product):
manage_runs_pg = MozTrapManageRunsPage(mozwebqa_logged_in)
def test_that_user_can_create_and_delete_run(self, mozwebqa, login, product):
manage_runs_pg = MozTrapManageRunsPage(mozwebqa)
run = self.create_run(mozwebqa_logged_in, product=product)
run = self.create_run(mozwebqa, product=product)
manage_runs_pg.filter_form.filter_by(lookup='name', value=run['name'])
@ -28,19 +28,19 @@ class TestManageRunsPage(BaseTest):
Assert.false(manage_runs_pg.is_element_present(*run['manage_locator']))
@pytest.mark.moztrap(3302)
def test_for_edit_active_run_that_includes_suites_to_be_sure_they_are_listed(self, mozwebqa_logged_in, product):
def test_for_edit_active_run_that_includes_suites_to_be_sure_they_are_listed(self, api, mozwebqa, login, product):
# create version
version = product['version']
# create two test suites
suite_a = self.create_suite(mozwebqa_logged_in, product=product, use_API=True, name='suite A')
suite_b = self.create_suite(mozwebqa_logged_in, product=product, use_API=True, name='suite B')
suite_a = self.create_suite(mozwebqa, product=product, api=api, name='suite A')
suite_b = self.create_suite(mozwebqa, product=product, api=api, name='suite B')
# create test run
suite_order = [suite_b['name'], suite_a['name']]
test_run = self.create_run(
mozwebqa_logged_in, product=product,
mozwebqa, product=product,
version=version, suite_name_list=suite_order)
manage_runs_pg = MozTrapManageRunsPage(mozwebqa_logged_in)
manage_runs_pg = MozTrapManageRunsPage(mozwebqa)
manage_runs_pg.go_to_manage_runs_page()
manage_runs_pg.filter_form.filter_by(lookup='name', value=test_run['name'])
manage_runs_pg.activate_run(name=test_run['name'])

Просмотреть файл

@ -16,10 +16,10 @@ from pages.manage_suites_page import MozTrapManageSuitesPage
class TestManageSuitesPage(BaseTest):
@pytest.mark.moztrap([98, 99])
def test_that_user_can_create_and_delete_suite(self, mozwebqa_logged_in, product):
manage_suites_pg = MozTrapManageSuitesPage(mozwebqa_logged_in)
def test_that_user_can_create_and_delete_suite(self, mozwebqa, login, product):
manage_suites_pg = MozTrapManageSuitesPage(mozwebqa)
suite = self.create_suite(mozwebqa_logged_in, product, use_API=False)
suite = self.create_suite(mozwebqa, product)
manage_suites_pg.filter_form.filter_by(lookup='name', value=suite['name'])
@ -29,11 +29,11 @@ class TestManageSuitesPage(BaseTest):
Assert.false(manage_suites_pg.is_element_present(*suite['locator']))
def test_that_user_can_create_suite_and_add_some_cases_to_it(self, mozwebqa_logged_in, product):
manage_suites_pg = MozTrapManageSuitesPage(mozwebqa_logged_in)
def test_that_user_can_create_suite_and_add_some_cases_to_it(self, api, mozwebqa, login, product):
manage_suites_pg = MozTrapManageSuitesPage(mozwebqa)
cases = [self.create_case(mozwebqa=mozwebqa_logged_in, product=product, use_API=True) for i in range(3)]
suite = self.create_suite(mozwebqa=mozwebqa_logged_in, product=product, use_API=True, case_list=[case for case in cases])
cases = [self.create_case(mozwebqa=mozwebqa, product=product, api=api) for i in range(3)]
suite = self.create_suite(mozwebqa=mozwebqa, product=product, api=api, case_list=[case for case in cases])
manage_suites_pg.go_to_manage_suites_page()
manage_suites_pg.filter_form.filter_by(lookup='name', value=suite['name'])
@ -45,15 +45,15 @@ class TestManageSuitesPage(BaseTest):
Assert.true(manage_test_cases_pg.is_case_present(case))
@pytest.mark.moztrap(2743)
def test_editing_of_existing_suite_that_has_no_included_cases(self, mozwebqa_logged_in, product):
def test_editing_of_existing_suite_that_has_no_included_cases(self, api, mozwebqa, login, product):
# create suite and cases
suite = self.create_suite(mozwebqa_logged_in, product, use_API=True)
cases = self.create_bulk_cases(mozwebqa_logged_in, product, use_API=True, cases_amount=3)
suite = self.create_suite(mozwebqa, product, api=api)
cases = self.create_bulk_cases(mozwebqa, product, api=api, cases_amount=3)
# simulate random order of cases
case_list = [cases[i]['name'] for i in (2, 0, 1)]
manage_suites_pg = MozTrapManageSuitesPage(mozwebqa_logged_in)
manage_suites_pg = MozTrapManageSuitesPage(mozwebqa)
manage_suites_pg.go_to_manage_suites_page()
manage_suites_pg.filter_form.filter_by(lookup='name', value=suite['name'])
edit_suite_pg = manage_suites_pg.edit_suite(name=suite['name'])
@ -76,14 +76,14 @@ class TestManageSuitesPage(BaseTest):
u'items are listed in wrong order')
@pytest.mark.moztrap(2742)
def test_editing_of_existing_suite_that_includes_cases(self, mozwebqa_logged_in, product):
def test_editing_of_existing_suite_that_includes_cases(self, api, mozwebqa, login, product):
# create suite and cases (both included and not included into suite)
included_cases = self.create_bulk_cases(mozwebqa_logged_in, product, use_API=True, cases_amount=2)
not_included_cases = self.create_bulk_cases(mozwebqa_logged_in, product, use_API=True, cases_amount=3)
suite = self.create_suite(mozwebqa_logged_in, product, use_API=True, case_list=[case for case in included_cases])
included_cases = self.create_bulk_cases(mozwebqa, product, api=api, cases_amount=2)
not_included_cases = self.create_bulk_cases(mozwebqa, product, api=api, cases_amount=3)
suite = self.create_suite(mozwebqa, product, api=api, case_list=[case for case in included_cases])
# filter by suite name and go to edit suite page
manage_suites_pg = MozTrapManageSuitesPage(mozwebqa_logged_in)
manage_suites_pg = MozTrapManageSuitesPage(mozwebqa)
manage_suites_pg.go_to_manage_suites_page()
manage_suites_pg.filter_form.filter_by(lookup='name', value=suite['name'])
edit_suite_pg = manage_suites_pg.edit_suite(name=suite['name'])

Просмотреть файл

@ -14,8 +14,8 @@ from pages.manage_cases_page import MozTrapManageCasesPage
class TestManageTagsPage(BaseTest):
def test_creating_a_tag_with_no_product_value_set(self, mozwebqa_logged_in):
manage_tags_pg = MozTrapManageTagsPage(mozwebqa_logged_in)
def test_creating_a_tag_with_no_product_value_set(self, mozwebqa, login):
manage_tags_pg = MozTrapManageTagsPage(mozwebqa)
manage_tags_pg.go_to_manage_tags_page()
create_tag_pg = manage_tags_pg.click_create_tag_button()
@ -31,8 +31,8 @@ class TestManageTagsPage(BaseTest):
Assert.true(tag['name'] in [t.name for t in displayed_tags],
'tag with "%s" name is not displayed on the page' % tag['name'])
def test_creating_a_tag_with_a_product_value_and_no_cases(self, mozwebqa_logged_in, product):
manage_tags_pg = MozTrapManageTagsPage(mozwebqa_logged_in)
def test_creating_a_tag_with_a_product_value_and_no_cases(self, mozwebqa, login, product):
manage_tags_pg = MozTrapManageTagsPage(mozwebqa)
manage_tags_pg.go_to_manage_tags_page()
create_tag_pg = manage_tags_pg.click_create_tag_button()
@ -49,10 +49,10 @@ class TestManageTagsPage(BaseTest):
Assert.true(tag['name'] in [t.name for t in displayed_tags],
'tag with "%s" name is not displayed on the page' % tag['name'])
def test_creating_a_tag_with_a_product_value_and_cases(self, mozwebqa_logged_in, product):
def test_creating_a_tag_with_a_product_value_and_cases(self, api, mozwebqa, login, product):
# create some cases for product
cases = self.create_bulk_cases(mozwebqa_logged_in, product, use_API=True)
manage_tags_pg = MozTrapManageTagsPage(mozwebqa_logged_in)
cases = self.create_bulk_cases(mozwebqa, product, api=api)
manage_tags_pg = MozTrapManageTagsPage(mozwebqa)
manage_tags_pg.go_to_manage_tags_page()
create_tag_pg = manage_tags_pg.click_create_tag_button()
@ -67,7 +67,7 @@ class TestManageTagsPage(BaseTest):
create_tag_pg.include_caseversions_to_tag(expected_case_names)
manage_cases_page = MozTrapManageCasesPage(mozwebqa_logged_in)
manage_cases_page = MozTrapManageCasesPage(mozwebqa)
manage_cases_page.go_to_manage_cases_page()
manage_cases_page.filter_form.filter_by(lookup='tag', value=tag['name'])

Просмотреть файл

@ -15,10 +15,10 @@ from pages.manage_versions_page import MozTrapManageVersionsPage
class TestManageVersionsPage(BaseTest):
@pytest.mark.moztrap([3389, 3390])
def test_that_user_can_create_and_delete_version(self, mozwebqa_logged_in, product):
manage_versions_pg = MozTrapManageVersionsPage(mozwebqa_logged_in)
def test_that_user_can_create_and_delete_version(self, mozwebqa, login, product):
manage_versions_pg = MozTrapManageVersionsPage(mozwebqa)
version = self.create_version(mozwebqa_logged_in, product)
version = self.create_version(mozwebqa, product)
manage_versions_pg.filter_form.filter_by(lookup='version', value=version['name'])
@ -29,10 +29,10 @@ class TestManageVersionsPage(BaseTest):
Assert.false(manage_versions_pg.is_element_present(*version['manage_locator']))
@pytest.mark.moztrap(3391)
def test_that_user_can_filter_version_by_name(self, mozwebqa_logged_in, product):
manage_versions_pg = MozTrapManageVersionsPage(mozwebqa_logged_in)
def test_that_user_can_filter_version_by_name(self, mozwebqa, login, product):
manage_versions_pg = MozTrapManageVersionsPage(mozwebqa)
version = self.create_version(mozwebqa_logged_in, product)
version = self.create_version(mozwebqa, product)
filter_item = manage_versions_pg.filter_form.filter_by(lookup='version', value='Another Version')
@ -44,10 +44,10 @@ class TestManageVersionsPage(BaseTest):
Assert.true(manage_versions_pg.is_element_present(*version['manage_locator']))
@pytest.mark.moztrap(3392)
def test_that_user_can_clone_version(self, mozwebqa_logged_in, product):
manage_versions_pg = MozTrapManageVersionsPage(mozwebqa_logged_in)
def test_that_user_can_clone_version(self, mozwebqa, login, product):
manage_versions_pg = MozTrapManageVersionsPage(mozwebqa)
version = self.create_version(mozwebqa_logged_in, product)
version = self.create_version(mozwebqa, product)
manage_versions_pg.filter_form.filter_by(lookup='version', value=version['name'])

Просмотреть файл

@ -18,10 +18,10 @@ from pages.view_run_results_page import MozTrapViewRunResultsPage
class TestPinningFilters(BaseTest):
@pytest.mark.moztrap(5935)
def test_that_pinning_filter_on_product_version_set_defaults_in_new_run(self, mozwebqa_logged_in, product):
def test_that_pinning_filter_on_product_version_set_defaults_in_new_run(self, mozwebqa, login, product):
product_version_name = u'%s %s' % (product['name'], product['version']['name'])
manage_runs_pg = MozTrapManageRunsPage(mozwebqa_logged_in)
manage_runs_pg = MozTrapManageRunsPage(mozwebqa)
manage_runs_pg.go_to_manage_runs_page()
filter_item = manage_runs_pg.filter_form.filter_by(lookup='productversion', value=product_version_name)
@ -40,16 +40,16 @@ class TestPinningFilters(BaseTest):
u'default product version is incorrect')
@pytest.mark.moztrap(5930)
def test_that_pinning_name_field_filter_only_works_for_current_page(self, mozwebqa_logged_in, product):
def test_that_pinning_name_field_filter_only_works_for_current_page(self, api, mozwebqa, login, product):
good_case_name = u'mozilla'
good_suite_name = u'MozTrap'
self.create_bulk_cases(mozwebqa_logged_in, product, use_API=True, name=good_case_name, cases_amount=3)
self.create_bulk_cases(mozwebqa_logged_in, product, use_API=True, name=u'ALLIZOM', cases_amount=2)
self.create_suite(mozwebqa_logged_in, product, use_API=True, name=good_suite_name)
self.create_suite(mozwebqa_logged_in, product, use_API=True, name=u'PartZom')
self.create_bulk_cases(mozwebqa, product, api=api, name=good_case_name, cases_amount=3)
self.create_bulk_cases(mozwebqa, product, api=api, name=u'ALLIZOM', cases_amount=2)
self.create_suite(mozwebqa, product, api=api, name=good_suite_name)
self.create_suite(mozwebqa, product, api=api, name=u'PartZom')
manage_cases_pg = MozTrapManageCasesPage(mozwebqa_logged_in)
manage_cases_pg = MozTrapManageCasesPage(mozwebqa)
manage_cases_pg.go_to_manage_cases_page()
# filter cases by name and assert that only cases with mozilla in their name are found
@ -63,7 +63,7 @@ class TestPinningFilters(BaseTest):
cases_filter.pin_filter()
self.check_pinned_filter(cases_filter, is_pinned=True)
manage_suites_pg = MozTrapManageSuitesPage(mozwebqa_logged_in)
manage_suites_pg = MozTrapManageSuitesPage(mozwebqa)
manage_suites_pg.go_to_manage_suites_page()
# check that there is no filters applied
@ -97,15 +97,15 @@ class TestPinningFilters(BaseTest):
Assert.contains(good_suite_name, suite.name)
# and go to manage runs page and see no filters there
manage_runs_pg = MozTrapManageRunsPage(mozwebqa_logged_in)
manage_runs_pg = MozTrapManageRunsPage(mozwebqa)
manage_runs_pg.go_to_manage_runs_page()
# check that there is no filters applied
Assert.equal(manage_runs_pg.filter_form.filter_items, [])
@pytest.mark.moztrap(5933)
def test_that_pinning_filters_on_product_sets_defaults_in_new_suite(self, mozwebqa_logged_in, product):
manage_suites_pg = MozTrapManageSuitesPage(mozwebqa_logged_in)
def test_that_pinning_filters_on_product_sets_defaults_in_new_suite(self, mozwebqa, login, product):
manage_suites_pg = MozTrapManageSuitesPage(mozwebqa)
manage_suites_pg.go_to_manage_suites_page()
filter_item = manage_suites_pg.filter_form.filter_by(lookup='product', value=product['name'])
@ -125,12 +125,12 @@ class TestPinningFilters(BaseTest):
@pytest.mark.moztrap(5932)
@pytest.mark.xfail(reason='Bug 1008850 - Suggestion box is cut off when the filter is too long')
def test_that_pinning_filters_on_product_and_version_and_suite_set_defaults_in_new_case(self, mozwebqa_logged_in, product):
def test_that_pinning_filters_on_product_and_version_and_suite_set_defaults_in_new_case(self, api, mozwebqa, login, product):
version = product['version']
product_version_name = u'%s %s' % (product['name'], version['name'])
suite = self.create_suite(mozwebqa_logged_in, product=product, use_API=True)
suite = self.create_suite(mozwebqa, product=product, api=api)
manage_cases_pg = MozTrapManageCasesPage(mozwebqa_logged_in)
manage_cases_pg = MozTrapManageCasesPage(mozwebqa)
manage_cases_pg.go_to_manage_cases_page()
filters = []
@ -157,8 +157,8 @@ class TestPinningFilters(BaseTest):
Assert.equal(create_bulk_cases_pg.suite_value, suite['name'])
@pytest.mark.moztrap(5936)
def test_that_pinning_filter_on_product_sets_defaults_in_new_product_version(self, mozwebqa_logged_in, product):
manage_versions_pg = MozTrapManageVersionsPage(mozwebqa_logged_in)
def test_that_pinning_filter_on_product_sets_defaults_in_new_product_version(self, mozwebqa, login, product):
manage_versions_pg = MozTrapManageVersionsPage(mozwebqa)
manage_versions_pg.go_to_manage_versions_page()
filter_item = manage_versions_pg.filter_form.filter_by(lookup='product', value=product['name'])
@ -177,13 +177,13 @@ class TestPinningFilters(BaseTest):
u'default product is incorrect')
@pytest.mark.moztrap(5931)
def test_that_pinning_filter_persists_for_session(self, mozwebqa_logged_in, product, element):
def test_that_pinning_filter_persists_for_session(self, api, mozwebqa, existing_user, login, product, element):
# create suite, cases and test run
product_version_name = u'%s %s' % (product['name'], product['version']['name'])
case, suite, run = self.create_and_run_test(mozwebqa_logged_in, product, element)
case, suite, run = self.create_and_run_test(api, mozwebqa, product, element)
# go to manage cases page
manage_cases_pg = MozTrapManageCasesPage(mozwebqa_logged_in)
manage_cases_pg = MozTrapManageCasesPage(mozwebqa)
manage_cases_pg.go_to_manage_cases_page()
# filter on product
@ -201,7 +201,7 @@ class TestPinningFilters(BaseTest):
self.check_pinned_filter(filter_item, is_pinned=True)
# go to manage suites page
manage_suites_pg = MozTrapManageSuitesPage(mozwebqa_logged_in)
manage_suites_pg = MozTrapManageSuitesPage(mozwebqa)
manage_suites_pg.go_to_manage_suites_page()
# see only suites for specified product
@ -211,7 +211,7 @@ class TestPinningFilters(BaseTest):
'displayed suite name differs from expected value')
# go to results page
view_results_pg = MozTrapViewRunResultsPage(mozwebqa_logged_in)
view_results_pg = MozTrapViewRunResultsPage(mozwebqa)
view_results_pg.go_to_view_run_results_page()
# see only results for specified product
@ -233,7 +233,7 @@ class TestPinningFilters(BaseTest):
# log out and back in and see that filter persists
view_results_pg.header.click_logout()
view_results_pg.header.click_login()
view_results_pg.header.login(existing_user['email'], existing_user['password'])
check_test_run_results(view_results_pg.test_run_results)
# check that filter is still pinned

Просмотреть файл

@ -16,10 +16,10 @@ from pages.manage_runs_page import MozTrapManageRunsPage
class TestRunTestsPage(BaseTest):
@pytest.mark.moztrap([205, 208])
def test_that_user_can_pass_test(self, mozwebqa_logged_in, product, element):
case = self.create_and_run_test(mozwebqa_logged_in, product, element)[0]
def test_that_user_can_pass_test(self, api, mozwebqa, login, product, element):
case = self.create_and_run_test(api, mozwebqa, product, element)[0]
run_tests_pg = MozTrapRunTestsPage(mozwebqa_logged_in)
run_tests_pg = MozTrapRunTestsPage(mozwebqa)
result = run_tests_pg.get_test_result(case['name'])
Assert.false(result.is_test_passed)
@ -29,10 +29,10 @@ class TestRunTestsPage(BaseTest):
Assert.true(result.is_test_passed)
@pytest.mark.moztrap(206)
def test_that_user_can_fail_test(self, mozwebqa_logged_in, product, element):
case = self.create_and_run_test(mozwebqa_logged_in, product, element)[0]
def test_that_user_can_fail_test(self, api, mozwebqa, login, product, element):
case = self.create_and_run_test(api, mozwebqa, product, element)[0]
run_tests_pg = MozTrapRunTestsPage(mozwebqa_logged_in)
run_tests_pg = MozTrapRunTestsPage(mozwebqa)
result = run_tests_pg.get_test_result(case['name'])
Assert.false(result.is_test_failed)
@ -42,10 +42,10 @@ class TestRunTestsPage(BaseTest):
Assert.true(result.is_test_failed)
@pytest.mark.moztrap(207)
def test_that_user_can_mark_test_invalid(self, mozwebqa_logged_in, product, element):
case = self.create_and_run_test(mozwebqa_logged_in, product, element)[0]
def test_that_user_can_mark_test_invalid(self, api, mozwebqa, login, product, element):
case = self.create_and_run_test(api, mozwebqa, product, element)[0]
run_tests_pg = MozTrapRunTestsPage(mozwebqa_logged_in)
run_tests_pg = MozTrapRunTestsPage(mozwebqa)
result = run_tests_pg.get_test_result(case['name'])
Assert.false(result.is_test_invalid)
@ -55,32 +55,32 @@ class TestRunTestsPage(BaseTest):
Assert.true(result.is_test_invalid)
@pytest.mark.moztrap(2744)
def test_that_test_run_saves_right_order_of_test_cases(self, mozwebqa_logged_in, product, element):
self.connect_product_to_element(mozwebqa_logged_in, product, element)
def test_that_test_run_saves_right_order_of_test_cases(self, api, mozwebqa, login, product, element):
self.connect_product_to_element(mozwebqa, product, element)
version = product['version']
# create several test case via bulk create
cases = self.create_bulk_cases(mozwebqa_logged_in, product, use_API=True, cases_amount=5)
cases = self.create_bulk_cases(mozwebqa, product, api=api, cases_amount=5)
# create first test suite
suite_a_cases = (cases[3], cases[1])
suite_a = self.create_suite(
mozwebqa_logged_in, product=product, use_API=True, name='suite A', case_list=suite_a_cases)
mozwebqa, product=product, api=api, name='suite A', case_list=suite_a_cases)
# create second test suite
suite_b_cases = (cases[2], cases[0], cases[4])
suite_b = self.create_suite(
mozwebqa_logged_in, product=product, use_API=True, name='suite B', case_list=suite_b_cases)
mozwebqa, product=product, api=api, name='suite B', case_list=suite_b_cases)
# create first test run (suite a, suite b)
first_suite_order = (suite_a['name'], suite_b['name'])
first_run = self.create_run(
mozwebqa_logged_in, product=product, activate=True,
mozwebqa, product=product, activate=True,
version=version, suite_name_list=first_suite_order)
# execute first test run
home_page = MozTrapHomePage(mozwebqa_logged_in)
home_page = MozTrapHomePage(mozwebqa)
home_page.go_to_home_page()
home_page.go_to_run_test(
product_name=product['name'], version_name=version['name'], run_name=first_run['name'],
env_category_name=element['category']['name'], env_element_name=element['name'])
run_tests_pg = MozTrapRunTestsPage(mozwebqa_logged_in)
run_tests_pg = MozTrapRunTestsPage(mozwebqa)
actual_order = [(item.case_name, item.suite_name) for item in run_tests_pg.test_results]
expected_order = [(case['name'], suite) for case in suite_a_cases for suite in (suite_a['name'],)] + \
@ -88,7 +88,7 @@ class TestRunTestsPage(BaseTest):
# assert that right order saved
Assert.equal(actual_order, expected_order)
# edit run to reorder suites
manage_runs_pg = MozTrapManageRunsPage(mozwebqa_logged_in)
manage_runs_pg = MozTrapManageRunsPage(mozwebqa)
manage_runs_pg.go_to_manage_runs_page()
# push run into draft mode
manage_runs_pg.filter_form.filter_by(lookup='name', value=first_run['name'])
@ -111,10 +111,10 @@ class TestRunTestsPage(BaseTest):
# assert that right order saved
Assert.equal(actual_order, expected_order)
def test_that_user_can_mark_test_as_blocked(self, mozwebqa_logged_in, product, element):
case = self.create_and_run_test(mozwebqa_logged_in, product, element)[0]
def test_that_user_can_mark_test_as_blocked(self, api, mozwebqa, login, product, element):
case = self.create_and_run_test(api, mozwebqa, product, element)[0]
run_tests_pg = MozTrapRunTestsPage(mozwebqa_logged_in)
run_tests_pg = MozTrapRunTestsPage(mozwebqa)
test_result = run_tests_pg.get_test_result(case['name'])
Assert.false(test_result.is_blocked)
@ -123,10 +123,10 @@ class TestRunTestsPage(BaseTest):
test_result = run_tests_pg.get_test_result(case['name'])
Assert.true(test_result.is_blocked)
def test_that_user_can_skip_test(self, mozwebqa_logged_in, product, element):
case = self.create_and_run_test(mozwebqa_logged_in, product, element)[0]
def test_that_user_can_skip_test(self, api, mozwebqa, login, product, element):
case = self.create_and_run_test(api, mozwebqa, product, element)[0]
run_tests_pg = MozTrapRunTestsPage(mozwebqa_logged_in)
run_tests_pg = MozTrapRunTestsPage(mozwebqa)
test_result = run_tests_pg.get_test_result(case['name'])
Assert.false(test_result.is_skipped)

13
variables.json Normal file
Просмотреть файл

@ -0,0 +1,13 @@
{
"users": {
"default": {
"email": "",
"password": "",
"name": ""
}
},
"api": {
"user": "",
"key": ""
}
}