Ejemplo n.º 1
0
    def test_load_testcases_by_path_folder(self):
        # absolute folder path
        path = os.path.join(os.getcwd(), 'tests/data')
        testset_list_1 = testcase.load_testsets_by_path(path)
        self.assertGreater(len(testset_list_1), 4)

        # relative folder path
        path = 'tests/data/'
        testset_list_2 = testcase.load_testsets_by_path(path)
        self.assertEqual(len(testset_list_1), len(testset_list_2))

        # list/set container with file(s)
        path = [os.path.join(os.getcwd(), 'tests/data'), 'tests/data/']
        testset_list_3 = testcase.load_testsets_by_path(path)
        self.assertEqual(len(testset_list_3), 2 * len(testset_list_1))
Ejemplo n.º 2
0
 def test_load_testcases_by_path_layered(self):
     path = os.path.join(os.getcwd(), 'tests/data/demo_testset_layer.yml')
     testsets_list = testcase.load_testsets_by_path(path)
     self.assertIn("variables", testsets_list[0]["config"])
     self.assertIn("request", testsets_list[0]["config"])
     self.assertIn("request", testsets_list[0]["testcases"][0])
     self.assertIn("url", testsets_list[0]["testcases"][0]["request"])
     self.assertIn("validate", testsets_list[0]["testcases"][0])
Ejemplo n.º 3
0
    def test_load_testcases_by_path_not_exist(self):
        # absolute folder path
        path = os.path.join(os.getcwd(), 'tests/data_not_exist')
        testset_list_1 = testcase.load_testsets_by_path(path)
        self.assertEqual(testset_list_1, [])

        # relative folder path
        path = 'tests/data_not_exist'
        testset_list_2 = testcase.load_testsets_by_path(path)
        self.assertEqual(testset_list_2, [])

        # list/set container with file(s)
        path = [
            os.path.join(os.getcwd(), 'tests/data_not_exist'),
            'tests/data_not_exist/'
        ]
        testset_list_3 = testcase.load_testsets_by_path(path)
        self.assertEqual(testset_list_3, [])
Ejemplo n.º 4
0
def init_task_suite(path_or_testsets, mapping=None, http_client_session=None):
    """ initialize task suite
    """
    if not testcase.is_testsets(path_or_testsets):
        testsets = testcase.load_testsets_by_path(path_or_testsets)
    else:
        testsets = path_or_testsets

    mapping = mapping or {}
    return TaskSuite(testsets, mapping, http_client_session)
Ejemplo n.º 5
0
 def test_run_testcase_with_empty_header(self):
     testcase_file_path = os.path.join(os.getcwd(),
                                       'tests/data/test_bugfix.yml')
     testsets = testcase.load_testsets_by_path(testcase_file_path)
     testset = testsets[0]
     config_dict_headers = testset["config"]["request"]["headers"]
     test_dict_headers = testset["testcases"][0]["request"]["headers"]
     headers = utils.deep_update_dict(config_dict_headers,
                                      test_dict_headers)
     self.assertEqual(headers["Content-Type"], "application/json")
Ejemplo n.º 6
0
    def test_load_testcases_by_path_files(self):
        testsets_list = []

        # absolute file path
        path = os.path.join(os.getcwd(),
                            'tests/data/demo_testset_hardcode.json')
        testset_list = testcase.load_testsets_by_path(path)
        self.assertEqual(len(testset_list), 1)
        self.assertIn("path", testset_list[0]["config"])
        self.assertEqual(testset_list[0]["config"]["path"], path)
        self.assertEqual(len(testset_list[0]["testcases"]), 3)
        testsets_list.extend(testset_list)

        # relative file path
        path = 'tests/data/demo_testset_hardcode.yml'
        testset_list = testcase.load_testsets_by_path(path)
        self.assertEqual(len(testset_list), 1)
        self.assertIn("path", testset_list[0]["config"])
        self.assertIn(path, testset_list[0]["config"]["path"])
        self.assertEqual(len(testset_list[0]["testcases"]), 3)
        testsets_list.extend(testset_list)

        # list/set container with file(s)
        path = [
            os.path.join(os.getcwd(), 'tests/data/demo_testset_hardcode.json'),
            'tests/data/demo_testset_hardcode.yml'
        ]
        testset_list = testcase.load_testsets_by_path(path)
        self.assertEqual(len(testset_list), 2)
        self.assertEqual(len(testset_list[0]["testcases"]), 3)
        self.assertEqual(len(testset_list[1]["testcases"]), 3)
        testsets_list.extend(testset_list)
        self.assertEqual(len(testsets_list), 4)

        for testset in testsets_list:
            for test in testset["testcases"]:
                self.assertIn('name', test)
                self.assertIn('request', test)
                self.assertIn('url', test['request'])
                self.assertIn('method', test['request'])