Skip to content

Commit afb82e7

Browse files
committed
Test Schema.dict
#3
1 parent af3ca47 commit afb82e7

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

tests/test_cli.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,4 +68,3 @@ def test_no_params():
6868

6969
assert result.exit_code == 0
7070
assert "Usage" in result.output
71-

tests/test_openapi_parser/test_openapi.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,3 +125,22 @@ def test__check_enums_bad_duplicate(self, mocker):
125125

126126
with pytest.raises(AssertionError):
127127
OpenAPI._check_enums([schema], [])
128+
129+
130+
class TestSchema:
131+
def test_dict(self, mocker):
132+
from_dict = mocker.patch(f"{MODULE_NAME}.Schema.from_dict")
133+
in_data = {1: mocker.MagicMock(), 2: mocker.MagicMock()}
134+
schema_1 = mocker.MagicMock()
135+
schema_2 = mocker.MagicMock()
136+
from_dict.side_effect = [schema_1, schema_2]
137+
138+
from openapi_python_client.openapi_parser.openapi import Schema
139+
140+
result = Schema.dict(in_data)
141+
142+
from_dict.assert_has_calls([mocker.call(value) for value in in_data.values()])
143+
assert result == {
144+
schema_1.reference.class_name: schema_1,
145+
schema_2.reference.class_name: schema_2,
146+
}

0 commit comments

Comments
 (0)