moztrap-tests/tests/test_run_tests_page.py

137 строки
6.2 KiB
Python
Исходник Обычный вид История

#!/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/.
2012-09-28 16:29:51 +04:00
import pytest
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
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]
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)
2014-02-10 00:39:51 +04:00
result.pass_test()
2014-02-10 00:39:51 +04:00
result = run_tests_pg.get_test_result(case['name'])
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]
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)
2014-02-10 00:39:51 +04:00
result.fail_test()
2014-02-10 00:39:51 +04:00
result = run_tests_pg.get_test_result(case['name'])
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]
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)
2014-02-10 00:39:51 +04:00
result.invalidate_test()
2014-02-10 00:39:51 +04:00
result = run_tests_pg.get_test_result(case['name'])
Assert.true(result.is_test_invalid)
2013-01-13 18:10:25 +04:00
@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)
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(
Squashed commit of the following: commit 7cc4402c9d5ce5c4af58e101b4d7df2b73c1a36e Author: Bob Silverberg <bob.silverberg@gmail.com> Date: Thu Apr 11 10:02:12 2013 -0400 Update to address @davehunt's comments: Remove unnecessary creating of api variable in fin() Remove extra line of code in MockProduct.__init__() Reorder function arguments to match new order for create_run() function commit ca841e531de69965b98899bd73852e01448f2af5 Author: Bob Silverberg <bob.silverberg@gmail.com> Date: Thu Apr 11 00:44:57 2013 -0400 Remove unused imports Remove nondestructive mark that is incorrect commit d48e4fbadc2a47516f56641e4369670500e95032 Author: Bob Silverberg <bob.silverberg@gmail.com> Date: Wed Apr 10 11:50:29 2013 -0400 Remove the need for the api pieces to need to understand mozwebqa.credentials Remove all the arguments to the __init__ method of MockProduct commit f85a1949bce0572ffa6e4b7e1e3d414be186896f Author: Bob Silverberg <bob.silverberg@gmail.com> Date: Mon Apr 8 11:42:29 2013 -0400 Remove profile argument from create_product API method commit 48f6b77bef2fd72eae5a6c5b8e59f0090a863cbe Author: Bob Silverberg <bob.silverberg@gmail.com> Date: Mon Apr 8 11:34:42 2013 -0400 Remove create_product from a few more tests commit dafd9ca7b539dac55ed3e168fac095046a0bd38a Merge: b7f6680 a4d2e60 Author: Bob Silverberg <bob.silverberg@gmail.com> Date: Mon Apr 8 10:53:39 2013 -0400 Merge branch 'master' into teardown Conflicts: tests/test_manage_suites_page.py commit b7f66801c9b4877ea62b0647fef1c68bce2f96d2 Author: Bob Silverberg <bob.silverberg@gmail.com> Date: Sun Apr 7 21:11:22 2013 -0400 Change conftest.py to auto-create and delete products via a 'product' method Remove page object reference and locators from mock product Change API to accept just credentials and base_url Do not return product from create_product Remove create_product_via_API method and test that just tests the creation via API Update tests that require a product to use API for both creation and deletion Eliminate all code the deletes products at the end of tests commit 9ce6ce66fd122c2640c9b3a7a77438f3d9a6b018 Author: Bob Silverberg <bob.silverberg@gmail.com> Date: Sun Mar 31 22:15:47 2013 -0400 Change _do_post return value on failure to None commit 7c9c29e046357f6847b6f3f87708d27fe68572ab Author: Bob Silverberg <bob.silverberg@gmail.com> Date: Wed Mar 27 09:21:18 2013 -0400 Update to address pull request comments: Move logic in api methods to _do_post and _do_delete Add api_key to sample credentials file Use username instead of name for api creds commit a8e6d2e431f7a665e267803037906876f7b5c16c Author: Bob Silverberg <bob.silverberg@gmail.com> Date: Wed Mar 20 13:30:43 2013 -0400 Moztrap automatic cleanup of products via API
2013-04-11 22:45:31 +04:00
mozwebqa_logged_in, product=product, activate=True,
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(
product_name=product['name'], version_name=version['name'], run_name=first_run['name'],
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
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'])
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(
product_name=product['name'], version_name=version['name'], run_name=first_run['name'],
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)