bravado.compat.json.loads

Here are the examples of the python api bravado.compat.json.loads taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

3 Examples 7

Example 1

Project: bravado Source File: conftest.py
@pytest.fixture
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())

Example 2

Project: bravado Source File: model_func_test.py
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.decode('utf-8'))
    assert {'schools': [{'name': 's1'}], 'id': 42} == body

Example 3

Project: bravado Source File: swagger_model.py
Function: json
        def json(self):
            return json.loads(self.text.decode('utf-8'))