@@ -534,11 +534,13 @@ def test_validation_error_when_location_not_supported(self, mocker):
534
534
with pytest .raises (pydantic .ValidationError ):
535
535
oai .Parameter (name = "test" , required = True , param_schema = mocker .MagicMock (), param_in = "error_location" )
536
536
537
- def test__add_parameters_with_location_postfix_conflict (self , mocker ):
537
+ def test__add_parameters_with_location_postfix_conflict1 (self , mocker ):
538
+ """Checks when the PythonIdentifier of new parameter already used"""
538
539
from openapi_python_client .parser .openapi import Endpoint
539
540
from openapi_python_client .parser .properties import Property
540
541
541
542
endpoint = self .make_endpoint ()
543
+
542
544
path_prop_name_conflicted = "prop_name_path"
543
545
path_prop_conflicted = mocker .MagicMock (autospec = Property )
544
546
path_prop_conflicted_import = mocker .MagicMock ()
@@ -592,6 +594,52 @@ def test__add_parameters_with_location_postfix_conflict(self, mocker):
592
594
assert isinstance (result , ParseError )
593
595
assert result .detail == "Parameters with same Python identifier `prop_name_path` detected"
594
596
597
+ def test__add_parameters_with_location_postfix_conflict2 (self , mocker ):
598
+ """Checks when an existing parameter has a conflicting PythonIdentifier after renaming."""
599
+ from openapi_python_client .parser .openapi import Endpoint
600
+ from openapi_python_client .parser .properties import Property
601
+
602
+ endpoint = self .make_endpoint ()
603
+ path_prop_conflicted = Property (
604
+ name = "prop_name_path" , required = False , nullable = False , default = None , python_name = "prop_name_path"
605
+ )
606
+ path_prop = Property (name = "prop_name" , required = False , nullable = False , default = None , python_name = "prop_name" )
607
+ query_prop = Property (name = "prop_name" , required = False , nullable = False , default = None , python_name = "prop_name" )
608
+ schemas_1 = mocker .MagicMock ()
609
+ schemas_2 = mocker .MagicMock ()
610
+ schemas_3 = mocker .MagicMock ()
611
+ property_from_data = mocker .patch (
612
+ f"{ MODULE_NAME } .property_from_data" ,
613
+ side_effect = [
614
+ (path_prop_conflicted , schemas_1 ),
615
+ (path_prop , schemas_2 ),
616
+ (query_prop , schemas_3 ),
617
+ ],
618
+ )
619
+ path_conflicted_schema = mocker .MagicMock ()
620
+ path_schema = mocker .MagicMock ()
621
+ query_schema = mocker .MagicMock ()
622
+
623
+ data = oai .Operation .construct (
624
+ parameters = [
625
+ oai .Parameter .construct (
626
+ name = path_prop_conflicted .name , required = True , param_schema = path_conflicted_schema , param_in = "path"
627
+ ),
628
+ oai .Parameter .construct (name = path_prop .name , required = True , param_schema = path_schema , param_in = "path" ),
629
+ oai .Parameter .construct (
630
+ name = query_prop .name , required = False , param_schema = query_schema , param_in = "query"
631
+ ),
632
+ oai .Reference .construct (), # Should be ignored
633
+ oai .Parameter .construct (), # Should be ignored
634
+ ]
635
+ )
636
+ initial_schemas = mocker .MagicMock ()
637
+ config = MagicMock ()
638
+
639
+ result = Endpoint ._add_parameters (endpoint = endpoint , data = data , schemas = initial_schemas , config = config )[0 ]
640
+ assert isinstance (result , ParseError )
641
+ assert result .detail == "Parameters with same Python identifier `prop_name_path` detected"
642
+
595
643
def test__add_parameters_happy (self , mocker ):
596
644
from openapi_python_client .parser .openapi import Endpoint
597
645
from openapi_python_client .parser .properties import Property
0 commit comments