MCPcopy Index your code
hub / github.com/httprunner/httprunner / test_parse_data_testcase

Method test_parse_data_testcase

httprunner/parser_test.py:453–484  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

451 self.assertEqual("abc4def", result["request"]["data"]["value"])
452
453 def test_parse_data_testcase(self):
454 variables = {
455 "uid": "1000",
456 "random": "A2dEx",
457 "authorization": "a83de0ff8d2e896dbd8efb81ba14e17d",
458 "data": {"name": "user", "password": "123456"},
459 }
460 functions = {
461 "add_two_nums": lambda a, b=1: a + b,
462 "get_timestamp": lambda: int(time.time() * 1000),
463 }
464 testcase_template = {
465 "url": "http://127.0.0.1:5000/api/users/$uid/${add_two_nums(1,2)}",
466 "method": "POST",
467 "headers": {
468 "Content-Type": "application/json",
469 "authorization": "$authorization",
470 "random": "$random",
471 "sum": "${add_two_nums(1, 2)}",
472 },
473 "body": "$data",
474 }
475 parsed_testcase = parser.parse_data(testcase_template, variables, functions)
476 self.assertEqual(
477 parsed_testcase["url"], "http://127.0.0.1:5000/api/users/1000/3"
478 )
479 self.assertEqual(
480 parsed_testcase["headers"]["authorization"], variables["authorization"]
481 )
482 self.assertEqual(parsed_testcase["headers"]["random"], variables["random"])
483 self.assertEqual(parsed_testcase["body"], variables["data"])
484 self.assertEqual(parsed_testcase["headers"]["sum"], 3)
485
486 def test_parse_parameters_testcase(self):
487 parameters = {

Callers

nothing calls this directly

Calls 1

parse_dataMethod · 0.80

Tested by

no test coverage detected