change: update unit tests for removing v1 format

This commit is contained in:
debugtalk
2020-04-09 11:46:13 +08:00
parent d98fbc8da7
commit 7ba22b1389
37 changed files with 205 additions and 686 deletions

View File

@@ -115,18 +115,6 @@ class TestSuiteLoader(unittest.TestCase):
self.assertIn("teststeps", loaded_content)
self.assertEqual(len(loaded_content["teststeps"]), 2)
def test_load_test_file_testcase_v2(self):
for loaded_content in [
buildup.load_test_file("tests/testcases/setup.v2.yml"),
buildup.load_test_file("tests/testcases/setup.v2.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)
def test_load_test_file_testsuite(self):
for loaded_content in [
buildup.load_test_file("tests/testsuites/create_users.yml"),
@@ -143,22 +131,6 @@ class TestSuiteLoader(unittest.TestCase):
"create user and check result."
)
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."
)
def test_load_tests_api_file(self):
path = os.path.join(
os.getcwd(), 'tests/api/create_user.yml')
@@ -168,26 +140,6 @@ class TestSuiteLoader(unittest.TestCase):
self.assertEqual(len(api_list), 1)
self.assertEqual(api_list[0]["request"]["url"], "/api/users/$uid")
def test_load_tests_testcase_file(self):
# absolute file path
path = os.path.join(
os.getcwd(), 'tests/data/demo_testcase_hardcode.json')
tests_mapping = loader.load_cases(path)
project_mapping = tests_mapping["project_mapping"]
testcases_list = tests_mapping["testcases"]
self.assertEqual(len(testcases_list), 1)
self.assertEqual(len(testcases_list[0]["teststeps"]), 3)
self.assertIn("get_sign", project_mapping["functions"])
# relative file path
path = 'tests/data/demo_testcase_hardcode.yml'
tests_mapping = loader.load_cases(path)
project_mapping = tests_mapping["project_mapping"]
testcases_list = tests_mapping["testcases"]
self.assertEqual(len(testcases_list), 1)
self.assertEqual(len(testcases_list[0]["teststeps"]), 3)
self.assertIn("get_sign", project_mapping["functions"])
def test_load_tests_testcase_file_2(self):
testcase_file_path = os.path.join(
os.getcwd(), 'tests/data/demo_testcase.yml')

View File

@@ -62,28 +62,6 @@ class TestFileLoader(unittest.TestCase):
with self.assertRaises(exceptions.FileNotFound):
load.load_file(testcase_file_path)
def test_load_json_testcases(self):
testcase_file_path = os.path.join(
os.getcwd(), 'tests/data/demo_testcase_hardcode.json')
testcases = load.load_file(testcase_file_path)
self.assertEqual(len(testcases), 3)
test = testcases[0]["test"]
self.assertIn('name', test)
self.assertIn('request', test)
self.assertIn('url', test['request'])
self.assertIn('method', test['request'])
def test_load_yaml_testcases(self):
testcase_file_path = os.path.join(
os.getcwd(), 'tests/data/demo_testcase_hardcode.yml')
testcases = load.load_file(testcase_file_path)
self.assertEqual(len(testcases), 3)
test = testcases[0]["test"]
self.assertIn('name', test)
self.assertIn('request', test)
self.assertIn('url', test['request'])
self.assertIn('method', test['request'])
def test_load_csv_file_one_parameter(self):
csv_file_path = os.path.join(
os.getcwd(), 'tests/data/user_agent.csv')

View File

@@ -1,6 +1,6 @@
{
"$schema": "http://json-schema.org/draft-07/schema",
"description": "httprunner testcase schema v2 definition",
"description": "httprunner testcase schema definition",
"type": "object",
"definitions": {
"teststep": {
@@ -118,7 +118,7 @@
"type": "array",
"minItems": 1,
"items": {
"$ref": "testcase.schema.v2.json#/definitions/teststep"
"$ref": "testcase.schema.json#/definitions/teststep"
}
}
},

View File

@@ -1,6 +1,6 @@
{
"$schema": "http://json-schema.org/draft-07/schema",
"description": "httprunner testsuite schema v2 definition",
"description": "httprunner testsuite schema definition",
"type": "object",
"definitions": {
"testcase": {
@@ -35,7 +35,7 @@
"type": "array",
"minItems": 1,
"items": {
"$ref": "testsuite.schema.v2.json#/definitions/testcase"
"$ref": "testsuite.schema.json#/definitions/testcase"
}
}
},