@@ -578,7 +578,7 @@ def test_from_data_bad_responses(self, mocker):
578
578
579
579
assert result == parse_error
580
580
581
- def test_from_data (self , mocker ):
581
+ def test_from_data_standard (self , mocker ):
582
582
from openapi_python_client .parser .openapi import Endpoint
583
583
584
584
path = mocker .MagicMock ()
@@ -613,8 +613,56 @@ def test_from_data(self, mocker):
613
613
_add_responses .assert_called_once_with (_add_parameters .return_value , data .responses )
614
614
_add_body .assert_called_once_with (_add_responses .return_value , data )
615
615
616
- data .security = None
617
- _add_parameters .reset_mock ()
616
+ def test_from_data_no_operation_id (self , mocker ):
617
+ from openapi_python_client .parser .openapi import Endpoint
618
+
619
+ path = "/path/with/{param}/"
620
+ method = "get"
621
+ _add_parameters = mocker .patch .object (Endpoint , "_add_parameters" )
622
+ _add_responses = mocker .patch .object (Endpoint , "_add_responses" )
623
+ _add_body = mocker .patch .object (Endpoint , "_add_body" )
624
+ data = oai .Operation .construct (
625
+ description = mocker .MagicMock (),
626
+ operationId = None ,
627
+ security = {"blah" : "bloo" },
628
+ responses = mocker .MagicMock (),
629
+ )
630
+
631
+ mocker .patch ("openapi_python_client.utils.remove_string_escapes" , return_value = data .description )
632
+
633
+ endpoint = Endpoint .from_data (data = data , path = path , method = method , tag = "default" )
634
+
635
+ assert endpoint == _add_body .return_value
636
+
637
+ _add_parameters .assert_called_once_with (
638
+ Endpoint (
639
+ path = path ,
640
+ method = method ,
641
+ description = data .description ,
642
+ name = "get_path_with_param" ,
643
+ requires_security = True ,
644
+ tag = "default" ,
645
+ ),
646
+ data ,
647
+ )
648
+ _add_responses .assert_called_once_with (_add_parameters .return_value , data .responses )
649
+ _add_body .assert_called_once_with (_add_responses .return_value , data )
650
+
651
+ def test_from_data_no_security (self , mocker ):
652
+ from openapi_python_client .parser .openapi import Endpoint
653
+
654
+ data = oai .Operation .construct (
655
+ description = mocker .MagicMock (),
656
+ operationId = mocker .MagicMock (),
657
+ security = None ,
658
+ responses = mocker .MagicMock (),
659
+ )
660
+ _add_parameters = mocker .patch .object (Endpoint , "_add_parameters" )
661
+ _add_responses = mocker .patch .object (Endpoint , "_add_responses" )
662
+ _add_body = mocker .patch .object (Endpoint , "_add_body" )
663
+ path = mocker .MagicMock ()
664
+ method = mocker .MagicMock ()
665
+ mocker .patch ("openapi_python_client.utils.remove_string_escapes" , return_value = data .description )
618
666
619
667
Endpoint .from_data (data = data , path = path , method = method , tag = "a" )
620
668
@@ -629,11 +677,8 @@ def test_from_data(self, mocker):
629
677
),
630
678
data ,
631
679
)
632
-
633
- data .operationId = None
634
- assert Endpoint .from_data (data = data , path = path , method = method , tag = "a" ) == ParseError (
635
- data = data , detail = "Path operations with operationId are not yet supported"
636
- )
680
+ _add_responses .assert_called_once_with (_add_parameters .return_value , data .responses )
681
+ _add_body .assert_called_once_with (_add_responses .return_value , data )
637
682
638
683
639
684
class TestImportStringFromReference :
0 commit comments