@@ -456,7 +456,7 @@ def test_from_data(self, mocker):
456456 "security" : {"blah" : "bloo" },
457457 }
458458
459- endpoint = Endpoint .from_data (data = data , path = path , method = method )
459+ endpoint = Endpoint .from_data (data = data , path = path , method = method , tag = "default" )
460460
461461 assert endpoint .path == path
462462 assert endpoint .method == method
@@ -468,10 +468,9 @@ def test_from_data(self, mocker):
468468 _add_responses .assert_called_once_with (data )
469469 _add_body .assert_called_once_with (data )
470470
471- data ["tags" ] = ["a" , "b" ]
472471 del data ["security" ]
473472
474- endpoint = Endpoint .from_data (data = data , path = path , method = method )
473+ endpoint = Endpoint .from_data (data = data , path = path , method = method , tag = "a" )
475474
476475 assert not endpoint .requires_security
477476 assert endpoint .tag == "a"
@@ -502,16 +501,16 @@ class TestEndpointCollection:
502501 def test_from_dict (self , mocker ):
503502 from openapi_python_client .openapi_parser .openapi import EndpointCollection , Endpoint
504503
505- data_1 = mocker . MagicMock ()
506- data_2 = mocker . MagicMock ()
507- data_3 = mocker . MagicMock ()
504+ data_1 = {}
505+ data_2 = { "tags" : [ "tag_2" , "tag_3" ]}
506+ data_3 = {}
508507 data = {
509- "path_1" : {"method_1" : data_1 , "method_2" : data_2 , },
510- "path_2" : {"method_1" : data_3 , },
508+ "path_1" : {"method_1" : data_1 , "method_2" : data_2 },
509+ "path_2" : {"method_1" : data_3 },
511510 }
512- endpoint_1 = mocker .MagicMock (autospec = Endpoint , tag = "tag_1 " , relative_imports = {"1" , "2" })
511+ endpoint_1 = mocker .MagicMock (autospec = Endpoint , tag = "default " , relative_imports = {"1" , "2" })
513512 endpoint_2 = mocker .MagicMock (autospec = Endpoint , tag = "tag_2" , relative_imports = {"2" })
514- endpoint_3 = mocker .MagicMock (autospec = Endpoint , tag = "tag_1 " , relative_imports = {"2" , "3" })
513+ endpoint_3 = mocker .MagicMock (autospec = Endpoint , tag = "default " , relative_imports = {"2" , "3" })
515514 endpoint_from_data = mocker .patch .object (
516515 Endpoint , "from_data" , side_effect = [endpoint_1 , endpoint_2 , endpoint_3 ]
517516 )
@@ -520,12 +519,41 @@ def test_from_dict(self, mocker):
520519
521520 endpoint_from_data .assert_has_calls (
522521 [
523- mocker .call (data = data_1 , path = "path_1" , method = "method_1" ),
524- mocker .call (data = data_2 , path = "path_1" , method = "method_2" ),
525- mocker .call (data = data_3 , path = "path_2" , method = "method_1" ),
522+ mocker .call (data = data_1 , path = "path_1" , method = "method_1" , tag = "default" ),
523+ mocker .call (data = data_2 , path = "path_1" , method = "method_2" , tag = "tag_2" ),
524+ mocker .call (data = data_3 , path = "path_2" , method = "method_1" , tag = "default" ),
526525 ]
527526 )
528527 assert result == {
529- "tag_1" : EndpointCollection ("tag_1" , endpoints = [endpoint_1 , endpoint_3 ], relative_imports = {"1" , "2" , "3" }),
528+ "default" : EndpointCollection (
529+ "default" , endpoints = [endpoint_1 , endpoint_3 ], relative_imports = {"1" , "2" , "3" }
530+ ),
530531 "tag_2" : EndpointCollection ("tag_2" , endpoints = [endpoint_2 ], relative_imports = {"2" }),
531532 }
533+
534+ def test_from_dict_errors (self , mocker ):
535+ from openapi_python_client .openapi_parser .openapi import EndpointCollection , Endpoint , ParseError
536+
537+ data_1 = {}
538+ data_2 = {"tags" : ["tag_2" , "tag_3" ]}
539+ data_3 = {}
540+ data = {
541+ "path_1" : {"method_1" : data_1 , "method_2" : data_2 },
542+ "path_2" : {"method_1" : data_3 },
543+ }
544+ endpoint_from_data = mocker .patch .object (
545+ Endpoint , "from_data" , side_effect = [ParseError ("1" ), ParseError ("2" ), ParseError ("3" )]
546+ )
547+
548+ result = EndpointCollection .from_dict (data )
549+
550+ endpoint_from_data .assert_has_calls (
551+ [
552+ mocker .call (data = data_1 , path = "path_1" , method = "method_1" , tag = "default" ),
553+ mocker .call (data = data_2 , path = "path_1" , method = "method_2" , tag = "tag_2" ),
554+ mocker .call (data = data_3 , path = "path_2" , method = "method_1" , tag = "default" ),
555+ ]
556+ )
557+ assert result ["default" ].parse_errors [0 ].data == "1"
558+ assert result ["default" ].parse_errors [1 ].data == "3"
559+ assert result ["tag_2" ].parse_errors [0 ].data == "2"
0 commit comments