Exemplo n.º 1
0
    def test_headers(self):
        self.uut = SwaggerClient.from_resource_listing(self.resource_listing)
        httpretty.register_uri(
            httpretty.GET, "http://swagger.py/swagger-test/pet",
            body='[]')

        self.uut.pet.listPets(
            _request_options={'headers': {'foo': 'bar'}}).result()
        self.assertEqual('bar', httpretty.last_request().headers['foo'])
Exemplo n.º 2
0
    def test_headers(self):
        self.uut = SwaggerClient.from_resource_listing(self.resource_listing)
        httpretty.register_uri(httpretty.GET,
                               "http://swagger.py/swagger-test/pet",
                               body='[]')

        self.uut.pet.listPets(_request_options={
            'headers': {
                'foo': 'bar'
            }
        }).result()
        self.assertEqual('bar', httpretty.last_request().headers['foo'])
Exemplo n.º 3
0
 def setUp(self):
     # Default handlers for all swagger.py access
     self.resource_listing = {
         u"swaggerVersion": u"1.2",
         u"basePath": u"http://swagger.py/swagger-test",
         u"apis": [
             {
                 u"path": u"/api-docs/pet.json",
                 u"description": u"Test loader when missing a file",
                 u"api_declaration": {
                     u"swaggerVersion": u"1.2",
                     u"basePath": u"http://swagger.py/swagger-test",
                     u"resourcePath": u"/pet.json",
                     u"apis": [
                         {
                             u"path": u"/pet",
                             u"operations": [
                                 {
                                     u"method": u"GET",
                                     u"nickname": u"listPets",
                                     u"type": u"array",
                                     u"items": {
                                         u"type": u"string"
                                     },
                                     u"parameters": []
                                 },
                                 {
                                     u"method": u"POST",
                                     u"nickname": u"createPet",
                                     u"type": u"string",
                                     u"parameters": [
                                         {
                                             u"name": u"name",
                                             u"paramType": u"query",
                                             u"type": u"string",
                                             u"required": True
                                         },
                                         {
                                             u"name": u"birthday",
                                             u"paramType": u"query",
                                             u"type": u"string",
                                             u"format": u"date",
                                             u"required": False
                                         }
                                     ]
                                 }
                             ]
                         },
                         {
                             u"path": u"/pet/find",
                             u"operations": [
                                 {
                                     u"method": u"GET",
                                     u"nickname": u"findPets",
                                     u"type": u"array",
                                     u"items": {
                                         u"type": u"string"
                                     },
                                     u"parameters": [
                                         {
                                             u"name": u"species",
                                             u"paramType": u"query",
                                             u"type": u"string",
                                             u"allowMultiple": True
                                         }
                                     ]
                                 }
                             ]
                         },
                         {
                             u"path": u"/pet/{petId}",
                             u"operations": [
                                 {
                                     u"method": u"DELETE",
                                     u"nickname": u"deletePet",
                                     u"type": u"void",
                                     u"parameters": [
                                         {
                                             u"name": u"petId",
                                             u"type": u"integer",
                                             u"paramType": u"path"
                                         }
                                     ]
                                 }
                             ]
                         },
                         {
                             u"path": u"/pet/{petId}/vaccine",
                             u"operations": [
                                 {
                                     u"method": u"POST",
                                     u"nickname": u"postVaccine",
                                     u"type": u"void",
                                     u"parameters": [
                                         {
                                             u"name": u"petId",
                                             u"type": u"integer",
                                             u"paramType": u"path"
                                         },
                                         {
                                             u"name": u"vaccineFile",
                                             u"type": u"File",
                                             u"paramType": u"form"
                                         }
                                     ]
                                 }
                             ]
                         }
                     ],
                     u"models": {}
                 }
             }
         ]
     }
     self.uut = SwaggerClient.from_resource_listing(self.resource_listing)
Exemplo n.º 4
0
 def setUp(self):
     # Default handlers for all swagger.py access
     self.resource_listing = {
         u"swaggerVersion":
         u"1.2",
         u"basePath":
         u"http://swagger.py/swagger-test",
         u"apis": [{
             u"path": u"/api-docs/pet.json",
             u"description": u"Test loader when missing a file",
             u"api_declaration": {
                 u"swaggerVersion":
                 u"1.2",
                 u"basePath":
                 u"http://swagger.py/swagger-test",
                 u"resourcePath":
                 u"/pet.json",
                 u"apis": [{
                     u"path":
                     u"/pet",
                     u"operations": [{
                         u"method": u"GET",
                         u"nickname": u"listPets",
                         u"type": u"array",
                         u"items": {
                             u"type": u"string"
                         },
                         u"parameters": []
                     }, {
                         u"method":
                         u"POST",
                         u"nickname":
                         u"createPet",
                         u"type":
                         u"string",
                         u"parameters": [{
                             u"name": u"name",
                             u"paramType": u"query",
                             u"type": u"string",
                             u"required": True
                         }, {
                             u"name": u"birthday",
                             u"paramType": u"query",
                             u"type": u"string",
                             u"format": u"date",
                             u"required": False
                         }]
                     }]
                 }, {
                     u"path":
                     u"/pet/find",
                     u"operations": [{
                         u"method":
                         u"GET",
                         u"nickname":
                         u"findPets",
                         u"type":
                         u"array",
                         u"items": {
                             u"type": u"string"
                         },
                         u"parameters": [{
                             u"name": u"species",
                             u"paramType": u"query",
                             u"type": u"string",
                             u"allowMultiple": True
                         }]
                     }]
                 }, {
                     u"path":
                     u"/pet/{petId}",
                     u"operations": [{
                         u"method":
                         u"DELETE",
                         u"nickname":
                         u"deletePet",
                         u"type":
                         u"void",
                         u"parameters": [{
                             u"name": u"petId",
                             u"type": u"integer",
                             u"paramType": u"path"
                         }]
                     }]
                 }, {
                     u"path":
                     u"/pet/{petId}/vaccine",
                     u"operations": [{
                         u"method":
                         u"POST",
                         u"nickname":
                         u"postVaccine",
                         u"type":
                         u"void",
                         u"parameters": [{
                             u"name": u"petId",
                             u"type": u"integer",
                             u"paramType": u"path"
                         }, {
                             u"name": u"vaccineFile",
                             u"type": u"File",
                             u"paramType": u"form"
                         }]
                     }]
                 }],
                 u"models": {}
             }
         }]
     }
     self.uut = SwaggerClient.from_resource_listing(self.resource_listing)