Skip to content

Commit a471025

Browse files
committed
Refactor test for PythonIdentifier of new parameter already used
1 parent a973637 commit a471025

File tree

1 file changed

+9
-21
lines changed

1 file changed

+9
-21
lines changed

tests/test_parser/test_openapi.py

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -535,29 +535,17 @@ def test_validation_error_when_location_not_supported(self, mocker):
535535
oai.Parameter(name="test", required=True, param_schema=mocker.MagicMock(), param_in="error_location")
536536

537537
def test__add_parameters_with_location_postfix_conflict1(self, mocker):
538-
"""Checks when the PythonIdentifier of new parameter already used"""
538+
"""Checks when the PythonIdentifier of new parameter already used."""
539539
from openapi_python_client.parser.openapi import Endpoint
540540
from openapi_python_client.parser.properties import Property
541541

542542
endpoint = self.make_endpoint()
543543

544-
path_prop_name_conflicted = "prop_name_path"
545-
path_prop_conflicted = mocker.MagicMock(autospec=Property)
546-
path_prop_conflicted_import = mocker.MagicMock()
547-
path_prop_conflicted.get_imports = mocker.MagicMock(return_value={path_prop_conflicted_import})
548-
path_prop_conflicted.python_name = "prop_name_path"
549-
550-
query_prop_name = "prop_name"
551-
query_prop = mocker.MagicMock(autospec=Property)
552-
query_prop_import = mocker.MagicMock()
553-
query_prop.get_imports = mocker.MagicMock(return_value={query_prop_import})
554-
query_prop.python_name = "prop_name_query"
555-
556-
path_prop_name = "prop_name"
557-
path_prop = mocker.MagicMock(autospec=Property)
558-
path_prop_import = mocker.MagicMock()
559-
path_prop.get_imports = mocker.MagicMock(return_value={path_prop_import})
560-
path_prop.python_name = "prop_name_path"
544+
path_prop_conflicted = Property(
545+
name="prop_name_path", required=False, nullable=False, default=None, python_name="prop_name_path"
546+
)
547+
query_prop = Property(name="prop_name", required=False, nullable=False, default=None, python_name="prop_name")
548+
path_prop = Property(name="prop_name", required=False, nullable=False, default=None, python_name="prop_name")
561549

562550
schemas_1 = mocker.MagicMock()
563551
schemas_2 = mocker.MagicMock()
@@ -577,12 +565,12 @@ def test__add_parameters_with_location_postfix_conflict1(self, mocker):
577565
data = oai.Operation.construct(
578566
parameters=[
579567
oai.Parameter.construct(
580-
name=path_prop_name_conflicted, required=True, param_schema=path_conflicted_schema, param_in="path"
568+
name=path_prop_conflicted.name, required=True, param_schema=path_conflicted_schema, param_in="path"
581569
),
582570
oai.Parameter.construct(
583-
name=query_prop_name, required=False, param_schema=query_schema, param_in="query"
571+
name=query_prop.name, required=False, param_schema=query_schema, param_in="query"
584572
),
585-
oai.Parameter.construct(name=path_prop_name, required=True, param_schema=path_schema, param_in="path"),
573+
oai.Parameter.construct(name=path_prop.name, required=True, param_schema=path_schema, param_in="path"),
586574
oai.Reference.construct(), # Should be ignored
587575
oai.Parameter.construct(), # Should be ignored
588576
]

0 commit comments

Comments
 (0)