Skip to content

Commit 5878f10

Browse files
committed
Added test for import_string_from_reference
#3
1 parent 96bd9a0 commit 5878f10

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

tests/test_openapi_parser/test_openapi.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,3 +225,24 @@ def test_parse_request_json_body_no_data(self):
225225
result = Endpoint.parse_request_json_body(body)
226226

227227
assert result is None
228+
229+
230+
class TestImportStringFromReference:
231+
def test_import_string_from_reference_no_prefix(self, mocker):
232+
from openapi_python_client.openapi_parser.openapi import import_string_from_reference
233+
from openapi_python_client.openapi_parser.reference import Reference
234+
235+
reference = mocker.MagicMock(autospec=Reference)
236+
result = import_string_from_reference(reference)
237+
238+
assert result == f"from .{reference.module_name} import {reference.class_name}"
239+
240+
def test_import_string_from_reference_with_prefix(self, mocker):
241+
from openapi_python_client.openapi_parser.openapi import import_string_from_reference
242+
from openapi_python_client.openapi_parser.reference import Reference
243+
244+
prefix = mocker.MagicMock(autospec=str)
245+
reference = mocker.MagicMock(autospec=Reference)
246+
result = import_string_from_reference(reference=reference, prefix=prefix)
247+
248+
assert result == f"from {prefix}.{reference.module_name} import {reference.class_name}"

0 commit comments

Comments
 (0)