2011-12-13 02:43:00 +04:00
|
|
|
#!/usr/bin/env python
|
2012-02-20 19:10:25 +04: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/.
|
2011-12-13 02:43:00 +04:00
|
|
|
|
2012-09-28 16:29:51 +04:00
|
|
|
import pytest
|
2011-12-13 02:43:00 +04:00
|
|
|
from unittestzero import Assert
|
|
|
|
|
2012-07-19 16:37:00 +04:00
|
|
|
from pages.base_test import BaseTest
|
2013-01-13 18:10:25 +04:00
|
|
|
from pages.home_page import MozTrapHomePage
|
2012-07-19 16:37:00 +04:00
|
|
|
from pages.run_tests_page import MozTrapRunTestsPage
|
2013-01-13 18:10:25 +04:00
|
|
|
from pages.manage_runs_page import MozTrapManageRunsPage
|
2012-07-19 16:37:00 +04:00
|
|
|
|
2011-12-13 02:43:00 +04:00
|
|
|
|
|
|
|
class TestRunTestsPage(BaseTest):
|
|
|
|
|
2012-09-28 23:36:36 +04:00
|
|
|
@pytest.mark.moztrap([205, 208])
|
2013-04-10 21:36:33 +04:00
|
|
|
def test_that_user_can_pass_test(self, mozwebqa_logged_in, product, element):
|
2013-07-19 01:05:55 +04:00
|
|
|
case = self.create_and_run_test(mozwebqa_logged_in, product, element)[0]
|
2011-12-13 02:43:00 +04:00
|
|
|
|
2014-02-10 00:39:51 +04:00
|
|
|
run_tests_pg = MozTrapRunTestsPage(mozwebqa_logged_in)
|
|
|
|
result = run_tests_pg.get_test_result(case['name'])
|
|
|
|
Assert.false(result.is_test_passed)
|
2011-12-13 02:43:00 +04:00
|
|
|
|
2014-02-10 00:39:51 +04:00
|
|
|
result.pass_test()
|
2011-12-13 02:43:00 +04:00
|
|
|
|
2014-02-10 00:39:51 +04:00
|
|
|
result = run_tests_pg.get_test_result(case['name'])
|
|
|
|
Assert.true(result.is_test_passed)
|
2011-12-13 02:43:00 +04:00
|
|
|
|
2012-09-28 23:36:36 +04:00
|
|
|
@pytest.mark.moztrap(206)
|
2013-04-10 21:36:33 +04:00
|
|
|
def test_that_user_can_fail_test(self, mozwebqa_logged_in, product, element):
|
2013-07-19 01:05:55 +04:00
|
|
|
case = self.create_and_run_test(mozwebqa_logged_in, product, element)[0]
|
2011-12-14 21:07:43 +04:00
|
|
|
|
2014-02-10 00:39:51 +04:00
|
|
|
run_tests_pg = MozTrapRunTestsPage(mozwebqa_logged_in)
|
|
|
|
result = run_tests_pg.get_test_result(case['name'])
|
|
|
|
Assert.false(result.is_test_failed)
|
2011-12-14 21:07:43 +04:00
|
|
|
|
2014-02-10 00:39:51 +04:00
|
|
|
result.fail_test()
|
2011-12-14 21:07:43 +04:00
|
|
|
|
2014-02-10 00:39:51 +04:00
|
|
|
result = run_tests_pg.get_test_result(case['name'])
|
|
|
|
Assert.true(result.is_test_failed)
|
2011-12-14 21:07:43 +04:00
|
|
|
|
2012-09-28 23:36:36 +04:00
|
|
|
@pytest.mark.moztrap(207)
|
2013-04-10 21:36:33 +04:00
|
|
|
def test_that_user_can_mark_test_invalid(self, mozwebqa_logged_in, product, element):
|
2013-07-19 01:05:55 +04:00
|
|
|
case = self.create_and_run_test(mozwebqa_logged_in, product, element)[0]
|
2011-12-14 21:49:37 +04:00
|
|
|
|
2014-02-10 00:39:51 +04:00
|
|
|
run_tests_pg = MozTrapRunTestsPage(mozwebqa_logged_in)
|
|
|
|
result = run_tests_pg.get_test_result(case['name'])
|
|
|
|
Assert.false(result.is_test_invalid)
|
2011-12-14 21:49:37 +04:00
|
|
|
|
2014-02-10 00:39:51 +04:00
|
|
|
result.invalidate_test()
|
2011-12-14 21:49:37 +04:00
|
|
|
|
2014-02-10 00:39:51 +04:00
|
|
|
result = run_tests_pg.get_test_result(case['name'])
|
|
|
|
Assert.true(result.is_test_invalid)
|
2011-12-14 21:49:37 +04:00
|
|
|
|
2013-01-13 18:10:25 +04:00
|
|
|
@pytest.mark.moztrap(2744)
|
2013-04-10 21:36:33 +04:00
|
|
|
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)
|
2013-01-13 18:10:25 +04:00
|
|
|
version = product['version']
|
2015-03-05 20:47:24 +03:00
|
|
|
# create several test case via bulk create
|
2013-05-27 22:14:52 +04:00
|
|
|
cases = self.create_bulk_cases(mozwebqa_logged_in, product, use_API=True, cases_amount=5)
|
2015-03-05 20:47:24 +03:00
|
|
|
# create first test suite
|
2013-05-27 22:14:52 +04:00
|
|
|
suite_a_cases = (cases[3], cases[1])
|
2013-01-13 18:10:25 +04:00
|
|
|
suite_a = self.create_suite(
|
2013-05-27 22:14:52 +04:00
|
|
|
mozwebqa_logged_in, product=product, use_API=True, name='suite A', case_list=suite_a_cases)
|
2015-03-05 20:47:24 +03:00
|
|
|
# create second test suite
|
2013-05-27 22:14:52 +04:00
|
|
|
suite_b_cases = (cases[2], cases[0], cases[4])
|
2013-01-13 18:10:25 +04:00
|
|
|
suite_b = self.create_suite(
|
2013-05-27 22:14:52 +04:00
|
|
|
mozwebqa_logged_in, product=product, use_API=True, name='suite B', case_list=suite_b_cases)
|
2015-03-05 20:47:24 +03:00
|
|
|
# create first test run (suite a, suite b)
|
2013-01-13 18:10:25 +04:00
|
|
|
first_suite_order = (suite_a['name'], suite_b['name'])
|
|
|
|
first_run = self.create_run(
|
2013-04-11 22:45:31 +04:00
|
|
|
mozwebqa_logged_in, product=product, activate=True,
|
2013-01-19 01:34:21 +04:00
|
|
|
version=version, suite_name_list=first_suite_order)
|
2015-03-05 20:47:24 +03:00
|
|
|
# execute first test run
|
2013-01-13 18:10:25 +04:00
|
|
|
home_page = MozTrapHomePage(mozwebqa_logged_in)
|
|
|
|
home_page.go_to_home_page()
|
|
|
|
home_page.go_to_run_test(
|
2013-01-19 01:34:21 +04:00
|
|
|
product_name=product['name'], version_name=version['name'], run_name=first_run['name'],
|
2013-04-10 21:36:33 +04:00
|
|
|
env_category_name=element['category']['name'], env_element_name=element['name'])
|
2013-01-13 18:10:25 +04:00
|
|
|
|
|
|
|
run_tests_pg = MozTrapRunTestsPage(mozwebqa_logged_in)
|
2014-02-10 00:39:51 +04:00
|
|
|
actual_order = [(item.case_name, item.suite_name) for item in run_tests_pg.test_results]
|
2013-01-13 18:10:25 +04:00
|
|
|
|
2013-05-27 22:14:52 +04:00
|
|
|
expected_order = [(case['name'], suite) for case in suite_a_cases for suite in (suite_a['name'],)] + \
|
|
|
|
[(case['name'], suite) for case in suite_b_cases for suite in (suite_b['name'],)]
|
2015-03-05 20:47:24 +03:00
|
|
|
# assert that right order saved
|
2013-01-13 18:10:25 +04:00
|
|
|
Assert.equal(actual_order, expected_order)
|
2015-03-05 20:47:24 +03:00
|
|
|
# edit run to reorder suites
|
2013-01-13 18:10:25 +04:00
|
|
|
manage_runs_pg = MozTrapManageRunsPage(mozwebqa_logged_in)
|
|
|
|
manage_runs_pg.go_to_manage_runs_page()
|
2015-03-05 20:47:24 +03:00
|
|
|
# push run into draft mode
|
2013-01-19 01:34:21 +04:00
|
|
|
manage_runs_pg.filter_form.filter_by(lookup='name', value=first_run['name'])
|
2013-01-13 18:10:25 +04:00
|
|
|
manage_runs_pg.make_run_draft(first_run['name'])
|
2015-03-05 20:47:24 +03:00
|
|
|
# go to edit run page and reorder suites by name (suite b, suite a)
|
2013-01-13 18:10:25 +04:00
|
|
|
edit_run_pg = manage_runs_pg.go_to_edit_run_page(first_run['name'])
|
2013-07-25 03:03:55 +04:00
|
|
|
edit_run_pg.edit_run(first_run, reorder_suites=True)
|
2015-03-05 20:47:24 +03:00
|
|
|
# make run active again
|
2013-01-13 18:10:25 +04:00
|
|
|
manage_runs_pg.activate_run(first_run['name'])
|
2015-03-05 20:47:24 +03:00
|
|
|
# execute run again
|
2013-01-13 18:10:25 +04:00
|
|
|
home_page.go_to_home_page()
|
|
|
|
home_page.go_to_run_test(
|
2013-01-19 01:34:21 +04:00
|
|
|
product_name=product['name'], version_name=version['name'], run_name=first_run['name'],
|
2013-04-10 21:36:33 +04:00
|
|
|
env_category_name=element['category']['name'], env_element_name=element['name'])
|
2015-03-05 20:47:24 +03:00
|
|
|
# check actual order of items on run tests page
|
2014-02-10 00:39:51 +04:00
|
|
|
actual_order = [(item.case_name, item.suite_name) for item in run_tests_pg.test_results]
|
2013-01-13 18:10:25 +04:00
|
|
|
|
2013-05-27 22:14:52 +04:00
|
|
|
expected_order = [(case['name'], suite) for case in suite_b_cases for suite in (suite_b['name'],)] + \
|
|
|
|
[(case['name'], suite) for case in suite_a_cases for suite in (suite_a['name'],)]
|
2015-03-05 20:47:24 +03:00
|
|
|
# assert that right order saved
|
2013-01-13 18:10:25 +04:00
|
|
|
Assert.equal(actual_order, expected_order)
|
2013-02-19 03:01:18 +04:00
|
|
|
|
2014-02-10 00:39:51 +04:00
|
|
|
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]
|
2013-02-19 03:01:18 +04:00
|
|
|
|
2014-02-10 00:39:51 +04:00
|
|
|
run_tests_pg = MozTrapRunTestsPage(mozwebqa_logged_in)
|
|
|
|
test_result = run_tests_pg.get_test_result(case['name'])
|
|
|
|
Assert.false(test_result.is_blocked)
|
|
|
|
|
|
|
|
test_result.mark_blocked()
|
|
|
|
|
|
|
|
test_result = run_tests_pg.get_test_result(case['name'])
|
|
|
|
Assert.true(test_result.is_blocked)
|
2014-03-07 10:56:03 +04:00
|
|
|
|
|
|
|
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]
|
|
|
|
|
|
|
|
run_tests_pg = MozTrapRunTestsPage(mozwebqa_logged_in)
|
|
|
|
test_result = run_tests_pg.get_test_result(case['name'])
|
|
|
|
Assert.false(test_result.is_skipped)
|
|
|
|
|
|
|
|
test_result.skip_test()
|
|
|
|
|
|
|
|
test_result = run_tests_pg.get_test_result(case['name'])
|
|
|
|
Assert.true(test_result.is_skipped)
|