@@ -15,20 +15,18 @@ def project_setup():
1515 sys .path .remove (project_dir )
1616
1717
18- @pytest .fixture
19- def app ():
20- from starletteproject .__main__ import app
21-
22- return app
23-
18+ class BaseTestPetstore :
19+ api_key = "12345"
2420
25- @pytest .fixture
26- def client ( app ):
27- return TestClient ( app , base_url = "http://petstore.swagger.io" )
21+ @pytest .fixture
22+ def app ( self ):
23+ from starletteproject . __main__ import app
2824
25+ return app
2926
30- class BaseTestPetstore :
31- api_key = "12345"
27+ @pytest .fixture
28+ def client (self , app ):
29+ return TestClient (app , base_url = "http://petstore.swagger.io" )
3230
3331 @property
3432 def api_key_encoded (self ):
@@ -37,6 +35,19 @@ def api_key_encoded(self):
3735 return str (api_key_bytes_enc , "utf8" )
3836
3937
38+ class BaseTestPetstoreSkipReponse :
39+
40+ @pytest .fixture
41+ def app (self ):
42+ from starletteproject .__main__ import app_skip_response
43+
44+ return app_skip_response
45+
46+ @pytest .fixture
47+ def client (self , app ):
48+ return TestClient (app , base_url = "http://petstore.swagger.io" )
49+
50+
4051class TestPetListEndpoint (BaseTestPetstore ):
4152 def test_get_no_required_param (self , client ):
4253 headers = {
@@ -381,3 +392,43 @@ def test_post_valid(self, client, data_gif):
381392
382393 assert not response .text
383394 assert response .status_code == 201
395+
396+
397+ class TestTagListEndpoint (BaseTestPetstore ):
398+
399+ def test_get_invalid (self , client ):
400+ headers = {
401+ "Authorization" : "Basic testuser" ,
402+ }
403+
404+ response = client .get (
405+ "/v1/tags" ,
406+ headers = headers ,
407+ )
408+
409+ assert response .status_code == 400
410+ assert response .json () == {
411+ "errors" : [
412+ {
413+ "title" : "Missing response data" ,
414+ "status" : 400 ,
415+ "type" : "<class 'openapi_core.validation.response.exceptions.MissingData'>" ,
416+ },
417+ ],
418+ }
419+
420+
421+ class TestSkipResponseTagListEndpoint (BaseTestPetstoreSkipReponse ):
422+
423+ def test_get_valid (self , client ):
424+ headers = {
425+ "Authorization" : "Basic testuser" ,
426+ }
427+
428+ response = client .get (
429+ "/v1/tags" ,
430+ headers = headers ,
431+ )
432+
433+ assert not response .text
434+ assert response .status_code == 201
0 commit comments