mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-12 02:21:29 +08:00
refactor mock server:
1, remove authentication switcher; 2, change authentication method: from verify request data's md5 to get token at the beginning.
This commit is contained in:
@@ -1,30 +1,29 @@
|
||||
import os
|
||||
import random
|
||||
import requests
|
||||
from tests.base import ApiServerUnittest
|
||||
from ate import task, utils
|
||||
|
||||
class TestMain(ApiServerUnittest):
|
||||
class TestTask(ApiServerUnittest):
|
||||
|
||||
def setUp(self):
|
||||
self.clear_users()
|
||||
self.reset_all()
|
||||
|
||||
def clear_users(self):
|
||||
url = "http://127.0.0.1:5000/api/users"
|
||||
return requests.delete(url)
|
||||
def reset_all(self):
|
||||
url = "%s/api/reset-all" % self.host
|
||||
headers = self.get_authenticated_headers()
|
||||
return self.api_client.get(url, headers=headers)
|
||||
|
||||
def test_create_suite(self):
|
||||
testcase_file_path = os.path.join(os.getcwd(), 'tests/data/simple_demo_no_auth.yml')
|
||||
testcase_file_path = os.path.join(os.getcwd(), 'tests/data/demo_testset_variables.yml')
|
||||
testsets = utils.load_testcases_by_path(testcase_file_path)
|
||||
suite = task.create_suite(testsets[0])
|
||||
self.assertEqual(suite.countTestCases(), 2)
|
||||
self.assertEqual(suite.countTestCases(), 3)
|
||||
for testcase in suite:
|
||||
self.assertIsInstance(testcase, task.ApiTestCase)
|
||||
|
||||
def test_create_task(self):
|
||||
testcase_file_path = os.path.join(os.getcwd(), 'tests/data/simple_demo_no_auth.yml')
|
||||
testcase_file_path = os.path.join(os.getcwd(), 'tests/data/demo_testset_variables.yml')
|
||||
task_suite = task.create_task(testcase_file_path)
|
||||
self.assertEqual(task_suite.countTestCases(), 2)
|
||||
self.assertEqual(task_suite.countTestCases(), 3)
|
||||
for suite in task_suite:
|
||||
for testcase in suite:
|
||||
self.assertIsInstance(testcase, task.ApiTestCase)
|
||||
|
||||
Reference in New Issue
Block a user