예제 #1
0
 def test_load_test_file_testcase(self):
     for loaded_content in [
             buildup.load_test_file("tests/testcases/setup.yml"),
             buildup.load_test_file("tests/testcases/setup.json")
     ]:
         self.assertEqual(loaded_content["type"], "testcase")
         self.assertIn("path", loaded_content)
         self.assertIn("config", loaded_content)
         self.assertEqual(loaded_content["config"]["name"],
                          "setup and reset all.")
         self.assertIn("teststeps", loaded_content)
         self.assertEqual(len(loaded_content["teststeps"]), 2)
예제 #2
0
    def test_load_test_file_testsuite_v2(self):
        for loaded_content in [
                buildup.load_test_file("tests/testsuites/create_users.v2.yml"),
                buildup.load_test_file("tests/testsuites/create_users.v2.json")
        ]:
            self.assertEqual(loaded_content["type"], "testsuite")

            testcases = loaded_content["testcases"]
            self.assertEqual(len(testcases), 2)
            self.assertIn('create user 1000 and check result.', testcases)
            self.assertIn('testcase_def',
                          testcases["create user 1000 and check result."])
            self.assertEqual(
                testcases["create user 1000 and check result."]["testcase_def"]
                ["config"]["name"], "create user and check result.")
예제 #3
0
    def test_load_yaml_file_file_format_error(self):
        yaml_tmp_file = "tests/data/tmp.yml"
        # create empty yaml file
        with open(yaml_tmp_file, 'w') as f:
            f.write("")

        with self.assertRaises(exceptions.FileFormatError):
            load_test_file(yaml_tmp_file)

        os.remove(yaml_tmp_file)

        # create invalid format yaml file
        with open(yaml_tmp_file, 'w') as f:
            f.write("abc")

        with self.assertRaises(exceptions.FileFormatError):
            load_test_file(yaml_tmp_file)

        os.remove(yaml_tmp_file)
예제 #4
0
    def test_load_json_file_file_format_error(self):
        json_tmp_file = "tests/data/tmp.json"
        # create empty file
        with open(json_tmp_file, 'w') as f:
            f.write("")

        with self.assertRaises(exceptions.FileFormatError):
            load_test_file(json_tmp_file)

        os.remove(json_tmp_file)

        # create empty json file
        with open(json_tmp_file, 'w') as f:
            f.write("{}")

        with self.assertRaises(exceptions.FileFormatError):
            load_test_file(json_tmp_file)

        os.remove(json_tmp_file)

        # create invalid format json file
        with open(json_tmp_file, 'w') as f:
            f.write("abc")

        with self.assertRaises(exceptions.FileFormatError):
            load_test_file(json_tmp_file)

        os.remove(json_tmp_file)
예제 #5
0
 def test_load_test_file_api(self):
     loaded_content = buildup.load_test_file("tests/api/create_user.yml")
     self.assertEqual(loaded_content["type"], "api")
     self.assertIn("path", loaded_content)
     self.assertIn("request", loaded_content)
     self.assertEqual(loaded_content["request"]["url"], "/api/users/$uid")