8
8
def test__collision_resolver ():
9
9
10
10
from openapi_python_client .resolver .collision_resolver import CollisionResolver
11
- from openapi_python_client .resolver .resolved_schema import ResolvedSchema
12
11
13
12
root_schema = {
14
13
"foobar" : {"$ref" : "first_instance.yaml#/foo" },
@@ -34,28 +33,34 @@ def test__collision_resolver():
34
33
"/home/user/fifth_instance.yaml" : {"foo" : {"description" : "foo_second_description" }},
35
34
}
36
35
37
- desired_result = {
38
- "foobar" : {"$ref" : "#/foo" },
39
- "barfoo" : {"$ref" : "#/foo_2" },
40
- "baz" : {"$ref" : "#/foo_2" },
41
- "barbarfoo" : {"$ref" : "#/foo_3" },
42
- "foobarfoo" : {"$ref" : "#/foo_2" },
43
- "barfoobar" : {"$ref" : "#/bar/foo" },
36
+ root_schema_result = {
37
+ "foobar" : {"$ref" : "first_instance.yaml#/foo" },
38
+ "barfoo" : {"$ref" : "second_instance.yaml#/foo_2" },
39
+ "barbarfoo" : {"$ref" : "third_instance.yaml#/foo_3" },
40
+ "foobarfoo" : {"$ref" : "second_instance.yaml#/foo_2" },
41
+ "barfoobar" : {"$ref" : "first_instance.yaml#/bar/foo" },
44
42
"localref" : {"$ref" : "#/local_ref" },
45
43
"local_ref" : {"description" : "a local ref" },
46
- "last" : {"$ref" : "#/fourth_instance" },
47
- "foo" : {"description" : "foo_first_description" },
48
- "foo_2" : {"description" : "foo_second_description" },
49
- "foo_3" : {"description" : "foo_third_description" },
50
- "bar" : {"foo" : {"description" : "nested foo" }},
51
- "foo_4" : {"description" : "foo_fourth_description" },
52
- "fourth_instance" : {"$ref" : "#/foo_4" },
44
+ "last" : {"$ref" : "first_instance.yaml#/fourth_instance" },
45
+ "baz" : {"$ref" : "fifth_instance.yaml#/foo_2" },
46
+ }
47
+
48
+ external_schemas_result = {
49
+ "/home/user/first_instance.yaml" : {
50
+ "foo" : {"description" : "foo_first_description" },
51
+ "bar" : {"foo" : {"description" : "nested foo" }},
52
+ "fourth_instance" : {"$ref" : "fourth_instance.yaml#/foo_4" },
53
+ },
54
+ "/home/user/second_instance.yaml" : {"foo_2" : {"description" : "foo_second_description" }},
55
+ "/home/user/third_instance.yaml" : {"foo_3" : {"description" : "foo_third_description" }},
56
+ "/home/user/fourth_instance.yaml" : {"foo_4" : {"description" : "foo_fourth_description" }},
57
+ "/home/user/fifth_instance.yaml" : {"foo_2" : {"description" : "foo_second_description" }},
53
58
}
59
+
54
60
errors = []
55
61
56
62
CollisionResolver (root_schema , external_schemas , errors , "/home/user" ).resolve ()
57
- resolved_schema = ResolvedSchema (root_schema , external_schemas , errors , "/home/user" ).schema
58
63
59
- print (resolved_schema )
60
64
assert len (errors ) == 0
61
- assert resolved_schema == desired_result
65
+ assert root_schema == root_schema_result
66
+ assert external_schemas == external_schemas_result
0 commit comments