def test_testcase_simple_run_suite(self): testcase_path = "tests/testcases/setup.yml" tests_mapping = loader.load_cases(testcase_path) testcases = parser.parse_tests(tests_mapping) runner = HttpRunner() test_suite = runner._add_tests(testcases) tests_results = runner._run_suite(test_suite) self.assertEqual(len(tests_results[0][1].records), 2)
def test_testsuite_add_tests(self): testcase_path = "tests/testsuites/create_users.yml" tests_mapping = loader.load_cases(testcase_path) testcases = parser.parse_tests(tests_mapping) runner = HttpRunner() test_suite = runner._add_tests(testcases) self.assertEqual(len(test_suite._tests), 2) tests = test_suite._tests[0].teststeps self.assertIn("setup and reset all (override)", tests[0]["config"]["name"].raw_string)
def test_testcase_add_tests(self): testcase_path = "tests/testcases/setup.yml" tests_mapping = loader.load_cases(testcase_path) testcases = parser.parse_tests(tests_mapping) runner = HttpRunner() test_suite = runner._add_tests(testcases) self.assertEqual(len(test_suite._tests), 1) teststeps = test_suite._tests[0].teststeps self.assertEqual(teststeps[0]["name"], "get token (setup)") self.assertEqual(teststeps[0]["variables"]["device_sn"], "TESTCASE_SETUP_XXX") self.assertIn("api", teststeps[0])
def test_testcase_complex_run_suite(self): testcase_path = "tests/testcases/create_user.yml" tests_mapping = loader.load_tests(testcase_path) testcases = parser.parse_tests(tests_mapping) runner = HttpRunner() test_suite = runner._add_tests(testcases) tests_results = runner._run_suite(test_suite) self.assertEqual(len(tests_results[0][1].records), 2) results = tests_results[0][1] self.assertEqual( results.records[0]["name"], "setup and reset all (override) for TESTCASE_CREATE_XXX.") self.assertEqual(results.records[1]["name"], "create user and check result.")
def test_testcase_complex_run_suite(self): testcase_path = "tests/testcases/create_and_check.yml" tests_mapping = loader.load_tests(testcase_path) parsed_tests_mapping = parser.parse_tests(tests_mapping) runner = HttpRunner() test_suite = runner._add_tests(parsed_tests_mapping) tests_results = runner._run_suite(test_suite) self.assertEqual(len(tests_results[0][1].records), 4) results = tests_results[0][1] self.assertEqual( results.records[0]["name"], "setup and reset all (override) for TESTCASE_CREATE_XXX.") self.assertEqual(results.records[1]["name"], "make sure user 9001 does not exist")
def test_testsuite_run_suite(self): testcase_path = "tests/testsuites/create_users.yml" tests_mapping = loader.load_tests(testcase_path) parsed_tests_mapping = parser.parse_tests(tests_mapping) runner = HttpRunner() test_suite = runner._add_tests(parsed_tests_mapping) tests_results = runner._run_suite(test_suite) self.assertEqual(len(tests_results[0][1].records), 4) results = tests_results[0][1] self.assertIn("setup and reset all (override)", results.records[0]["name"]) self.assertIn(results.records[1]["name"], [ "make sure user 1000 does not exist", "make sure user 1001 does not exist" ])