-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest_contract_generator.py
29 lines (22 loc) · 1.08 KB
/
test_contract_generator.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# Copyright 2021 Nokia
# Licensed under the BSD 3-Clause License.
# SPDX-License-Identifier: BSD-3-Clause
import json
import os
CURRENT_DIR = os.path.dirname(os.path.realpath(__file__))
def test_generation(rest_contract_generator,
request_dict,
json_response,
tmpdir):
rest_contract_generator.generate_and_save_contract(request_dict, json_response)
generated_json = os.path.join(tmpdir, "test_contract.json")
expected_json = os.path.join(CURRENT_DIR, "contracts", "example_contract.json")
with open(generated_json, encoding="UTF-8") as file1, \
open(expected_json, encoding="UTF-8") as file2:
assert json.load(file1) == json.load(file2)
def test_generation_without_rendering(rest_contract_generator,
request_dict,
json_response):
request_dict["url"] = "http://localhost/test"
request_dict.pop("headers")
rest_contract_generator.generate_and_save_contract(request_dict, json_response)