Пример #1
0
def test_model_in_body_of_request(httprettified, swagger_dict, sample_model):
    param_spec = {
        "in": "body",
        "name": "body",
        "schema": {
            "$ref": "#/definitions/User"
        }
    }
    swagger_dict["paths"]["/test_http"]['post']["parameters"] = [param_spec]
    register_spec(swagger_dict)
    httpretty.register_uri(httpretty.POST, "http://localhost/test_http")
    client = SwaggerClient.from_url(API_DOCS_URL)
    resource = client.api_test
    User = client.get_model('User')
    School = client.get_model('School')
    user = User(id=42, schools=[School(name='s1')])
    resource.testHTTPPost(body=user).result()
    body = json.loads(httpretty.last_request().body)
    assert {'schools': [{'name': 's1'}], 'id': 42} == body
Пример #2
0
def test_model_in_body_of_request(httprettified, swagger_dict, sample_model):
    param_spec = {
        "in": "body",
        "name": "body",
        "schema": {
            "$ref": "#/definitions/User"
        }
    }
    swagger_dict["paths"]["/test_http"]['post']["parameters"] = [param_spec]
    register_spec(swagger_dict)
    httpretty.register_uri(httpretty.POST, "http://localhost/test_http")
    client = SwaggerClient.from_url(API_DOCS_URL)
    resource = client.api_test
    User = client.get_model('User')
    School = client.get_model('School')
    user = User(id=42, schools=[School(name='s1')])
    resource.testHTTPPost(body=user).result()
    body = json.loads(httpretty.last_request().body)
    assert {'schools': [{'name': 's1'}], 'id': 42} == body
Пример #3
0
 def json(self):
     return json.loads(self.text.decode('utf-8'))
Пример #4
0
def petstore_dict():
    my_dir = os.path.abspath(os.path.dirname(__file__))
    fpath = os.path.join(my_dir, '../../test-data/2.0/petstore/swagger.json')
    with open(fpath) as f:
        return json.loads(f.read())
Пример #5
0
def petstore_dict():
    my_dir = os.path.abspath(os.path.dirname(__file__))
    fpath = os.path.join(my_dir, '../../test-data/2.0/petstore/swagger.json')
    with open(fpath) as f:
        return json.loads(f.read())
Пример #6
0
 def json(self):
     return json.loads(self.text.decode('utf-8'))
Пример #7
0
 def json(self):
     return json.loads(self.text)
Пример #8
0
 def json(self):
     return json.loads(self.text)