예제 #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
파일: conftest.py 프로젝트: akanak/bravado
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)