Ejemplo n.º 1
0
    def test_parameter(self):
        """ Parameter -> Parameter
        """
        # body
        o = self.app.root.paths["/api/pet/{petId}"].patch
        p = [p for p in o.parameters if getattr(p, "in") == "body"][0]
        self.assertEqual(getattr(p, "in"), "body")
        self.assertEqual(p.required, True)
        self.assertEqual(getattr(p.schema, "norm_ref"), _pf("/definitions/pet!##!Pet"))

        # form
        o = self.app.root.paths["/api/pet/uploadImage"].post
        p = [p for p in o.parameters if getattr(p, "in") == "formData" and p.type == "string"][0]
        self.assertEqual(p.name, "additionalMetadata")
        self.assertEqual(p.required, False)

        # file
        o = self.app.root.paths["/api/pet/uploadImage"].post
        p = [p for p in o.parameters if getattr(p, "in") == "formData" and p.type == "file"][0]
        self.assertEqual(p.name, "file")
        self.assertEqual(p.required, False)

        # non-body can't have $ref
        try:
            SwaggerApp._create_(get_test_data_folder(version="1.2", which="upgrade_parameter"))
        except errs.SchemaError as e:
            self.failUnlessEqual(e.args, ("Can't have $ref in non-body Parameters",))
        else:
            self.fail("SchemaError not raised")
Ejemplo n.º 2
0
    def test_parameter(self):
        """ Parameter -> Parameter
        """
        # body
        o = self.app.root.paths['/api/pet/{petId}'].patch
        p = [p for p in o.parameters if getattr(p, 'in') == 'body'][0]
        self.assertEqual(getattr(p, 'in'), 'body')
        self.assertEqual(p.required, True)
        self.assertEqual(getattr(p.schema, '$ref'), _pf('/definitions/pet!##!Pet'))

        # form
        o = self.app.root.paths['/api/pet/uploadImage'].post
        p = [p for p in o.parameters if getattr(p, 'in') == 'formData' and p.type == 'string'][0]
        self.assertEqual(p.name, 'additionalMetadata')
        self.assertEqual(p.required, False)
 
        # file
        o = self.app.root.paths['/api/pet/uploadImage'].post
        p = [p for p in o.parameters if getattr(p, 'in') == 'formData' and p.type == 'file'][0]
        self.assertEqual(p.name, 'file')
        self.assertEqual(p.required, False)

        # non-body can't have $ref
        try:
            SwaggerApp._create_(get_test_data_folder(
                version='1.2',
                which='upgrade_parameter'
            ))
        except errs.SchemaError as e:
            self.failUnlessEqual(e.args, ("Can't have $ref in non-body Parameters",))
        else:
            self.fail('SchemaError not raised')
Ejemplo n.º 3
0
    def test_item(self):
        """ make sure to raise exception for invalid item
        """
        try:
            SwaggerApp._create_(get_test_data_folder(version="1.2", which=os.path.join("upgrade_items", "with_ref")))
        except errs.SchemaError as e:
            self.failUnlessEqual(e.args, ("Can't have $ref for Items",))
        else:
            self.fail("SchemaError not raised")

        try:
            SwaggerApp._create_(
                get_test_data_folder(version="1.2", which=os.path.join("upgrade_items", "invalid_primitive"))
            )
        except errs.SchemaError as e:
            self.failUnlessEqual(e.args, ("Non primitive type is not allowed for Items",))
        else:
            self.fail("SchemaError not raised")
Ejemplo n.º 4
0
    def test_item(self):
        """ make sure to raise exception for invalid item
        """
        try:
            SwaggerApp._create_(get_test_data_folder(
                version='1.2',
                which=os.path.join('upgrade_items', 'with_ref')
            ))
        except errs.SchemaError as e:
            self.failUnlessEqual(e.args, ('Can\'t have $ref for Items',))
        else:
            self.fail('SchemaError not raised')

        try:
            SwaggerApp._create_(get_test_data_folder(
                version='1.2',
                which=os.path.join('upgrade_items', 'invalid_primitive')
            ))
        except errs.SchemaError as e:
            self.failUnlessEqual(e.args, ('Non primitive type is not allowed for Items',))
        else:
            self.fail('SchemaError not raised')
Ejemplo n.º 5
0
    def test_parameter(self):
        """ Parameter -> Parameter
        """
        # body
        o = self.app.root.paths['/api/pet/{petId}'].patch
        p = [p for p in o.parameters if getattr(p, 'in') == 'body'][0]
        self.assertEqual(getattr(p, 'in'), 'body')
        self.assertEqual(p.required, True)
        self.assertEqual(getattr(p.schema, 'norm_ref'),
                         _pf('/definitions/pet!##!Pet'))

        # form
        o = self.app.root.paths['/api/pet/uploadImage'].post
        p = [
            p for p in o.parameters
            if getattr(p, 'in') == 'formData' and p.type == 'string'
        ][0]
        self.assertEqual(p.name, 'additionalMetadata')
        self.assertEqual(p.required, False)

        # file
        o = self.app.root.paths['/api/pet/uploadImage'].post
        p = [
            p for p in o.parameters
            if getattr(p, 'in') == 'formData' and p.type == 'file'
        ][0]
        self.assertEqual(p.name, 'file')
        self.assertEqual(p.required, False)

        # non-body can't have $ref
        try:
            SwaggerApp._create_(
                get_test_data_folder(version='1.2', which='upgrade_parameter'))
        except errs.SchemaError as e:
            self.failUnlessEqual(e.args,
                                 ("Can't have $ref in non-body Parameters", ))
        else:
            self.fail('SchemaError not raised')
Ejemplo n.º 6
0
    def test_item(self):
        """ make sure to raise exception for invalid item
        """
        try:
            SwaggerApp._create_(
                get_test_data_folder(version='1.2',
                                     which=os.path.join(
                                         'upgrade_items', 'with_ref')))
        except errs.SchemaError as e:
            self.failUnlessEqual(e.args, ('Can\'t have $ref for Items', ))
        else:
            self.fail('SchemaError not raised')

        try:
            SwaggerApp._create_(
                get_test_data_folder(version='1.2',
                                     which=os.path.join(
                                         'upgrade_items',
                                         'invalid_primitive')))
        except errs.SchemaError as e:
            self.failUnlessEqual(
                e.args, ('Non primitive type is not allowed for Items', ))
        else:
            self.fail('SchemaError not raised')
Ejemplo n.º 7
0
def show_method_list(args):

    app = SwaggerApp._create_(args.spec)

    # TODO: determine url basepath from spec

    methods = []

    for method, op in app.op.items():

        query_params = []
        for p in op.parameters:
            if getattr(p, 'in') == 'query':
                query_params.append(p.name + "=" + p.type)

        path = op.path + ('?' + '&'.join(query_params)
                          if len(query_params) > 0 else '')

        methods.append((path, op))

    methods = sorted(methods, key=lambda m: m[0])

    for (path, op) in methods:

        # rows, cols = os.popen('stty size', 'r').read().split()

        if args.v:
            set_color()
            print(op.summary)
            set_color(op.method)
            print("{:<7}{:<50}".format(op.method.upper(), path))
            set_color()
            print(
                get_curl_command(urllib.parse.urljoin(args.spec, path[1:]),
                                 op.method) + '\n')
        else:
            summary = (op.summary[:15] +
                       '..') if len(op.summary) > 15 else op.summary
            # print ("{}{}{:<6}{}{}{}{} {:<50}{}{:>20}{}".format(Fore.WHITE, back_color(op.method), op.method.upper(), Style.DIM, Back.BLACK, Style.NORMAL, Fore.WHITE, path, fore_color(op.method), summary, Style.RESET_ALL))
            # set_color(op.method)
            print("{}{:<6}{} {:<50}{:>20}".format(fore_color(op.method),
                                                  op.method.upper(),
                                                  Style.RESET_ALL, path,
                                                  summary))
Ejemplo n.º 8
0
    def test_auto_schemes(self):
        """ make sure we scheme of url to access
        swagger.json as default scheme
        """
        # load swagger.json
        data = None
        with open(os.path.join(get_test_data_folder(
                version='2.0',
                which=os.path.join('schema', 'model')
                ), 'swagger.json')) as f:
            data = f.read()

        httpretty.register_uri(
            httpretty.GET,
            'http://test.com/api-doc/swagger.json',
            body=data
        )

        app = SwaggerApp._create_('http://test.com/api-doc/swagger.json')
        self.assertEqual(app.schemes, ['http'])
Ejemplo n.º 9
0
    def test_auto_schemes(self):
        """ make sure we scheme of url to access
        swagger.json as default scheme
        """
        # load swagger.json
        data = None
        with open(os.path.join(get_test_data_folder(
                version='2.0',
                which=os.path.join('schema', 'model')
                ), 'swagger.json')) as f:
            data = f.read()

        httpretty.register_uri(
            httpretty.GET,
            'http://test.com/api-doc/swagger.json',
            body=data
        )

        app = SwaggerApp._create_('http://test.com/api-doc/swagger.json')
        self.assertEqual(app.schemes, ['http'])
Ejemplo n.º 10
0
def get_method_list():

    from pyswagger import SwaggerApp, SwaggerSecurity
    from pyswagger.contrib.client.requests import Client
    from pyswagger.utils import jp_compose

    app = SwaggerApp._create_(swagger_spec)
    client = Client()

    methods = list(app.op.keys())

    apis = dict()

    for m in methods:

        full_method = m.split('!##!')

        if not full_method[0] in apis:
            apis[full_method[0]] = set()

        apis[full_method[0]].add(full_method[1])

    return apis
Ejemplo n.º 11
0
 def setUpClass(kls):
     kls.app = SwaggerApp._create_(
         get_test_data_folder(version='2.0',
                              which=os.path.join('resolve', 'deref')))
Ejemplo n.º 12
0
 def setUp(self):
     self.app = SwaggerApp._create_(get_test_data_folder(version='1.2', which='err'))
Ejemplo n.º 13
0
 def setUpClass(kls):
     kls.app = SwaggerApp._create_(get_test_data_folder(
         version='2.0',
         which='patch'
     ))
Ejemplo n.º 14
0
 def setUpClass(kls):
     kls.app = SwaggerApp._create_(get_test_data_folder(version="1.2", which="model_subtypes"))
Ejemplo n.º 15
0
 def setUpClass(kls):
     kls.app = SwaggerApp._create_(get_test_data_folder(version='1.2', which='wordnik'))
Ejemplo n.º 16
0
from pyswagger import SwaggerApp, SwaggerSecurity
from pyswagger.contrib.client.requests import Client
from pyswagger.utils import jp_compose

# load Swagger resource file into SwaggerApp object
app = SwaggerApp._create_('http://petstore.swagger.io/v2/swagger.json')

auth = SwaggerSecurity(app)
auth.update_with('api_key', '12312312312312312313q') # api key
auth.update_with('petstore_auth', '12334546556521123fsfss') # oauth2

# init swagger client
client = Client(auth)

# a dict is enough for representing a Model in Swagger
pet_Tom=dict(id=1, name='Tom', photoUrls=['http://test'])
# a request to create a new pet
client.request(app.op['addPet'](body=pet_Tom))

# - access an Operation object via SwaggerApp.op when operationId is defined
# - a request to get the pet back
pet = client.request(app.op['getPetById'](petId=1)).data
assert pet.id == 1
assert pet.name == 'Tom'

# new ways to get Operation object corresponding to 'getPetById'.
# 'jp_compose' stands for JSON-Pointer composition
pet = client.request(app.resolve(jp_compose('/pet/{petId}', base='#/paths')).get(petId=1)).data
assert pet.id == 1
Ejemplo n.º 17
0
 def setUpClass(kls):
     kls.app = SwaggerApp._create_(get_test_data_folder(version='2.0', which=os.path.join('schema', 'model')))
Ejemplo n.º 18
0
 def setUpClass(kls):
     kls.app = SwaggerApp._create_(get_test_data_folder(version='1.2', which='model_subtypes')) 
Ejemplo n.º 19
0
 def setUpClass(kls):
     kls.app = SwaggerApp._create_(get_test_data_folder(version="2.0", which=os.path.join("schema", "model")))
Ejemplo n.º 20
0
 def setUpClass(kls):
     kls.app = SwaggerApp._create_(folder)
Ejemplo n.º 21
0
    def test_http_getter(self):
        """ make sure HTTPGetter works """

        folder = get_test_data_folder(version='1.2', which='wordnik')
        resource_list = user = pet = store = None

        with open(os.path.join(folder, 'resource_list.json')) as f:
            resource_list = f.read()

        with open(os.path.join(folder, 'user.json')) as f:
            user = f.read()

        with open(os.path.join(folder, 'pet.json')) as f:
            pet = f.read()

        with open(os.path.join(folder, 'store.json')) as f:
            store = f.read()

        httpretty.register_uri(
            httpretty.GET, 'http://petstore.swagger.wordnik.com/api/api-docs',
            status=200,
            body=resource_list
            )

        httpretty.register_uri(
            httpretty.GET, 'http://petstore.swagger.wordnik.com/api/api-docs/user',
            status=200,
            body=user
            )

        httpretty.register_uri(
            httpretty.GET, 'http://petstore.swagger.wordnik.com/api/api-docs/pet',
            status=200,
            body=pet
            )

        httpretty.register_uri(
            httpretty.GET, 'http://petstore.swagger.wordnik.com/api/api-docs/store',
            status=200,
            body=store
            )

        local_app = SwaggerApp._create_('http://petstore.swagger.wordnik.com/api/api-docs')

        self.assertEqual(sorted(local_app.schema._field_names_), sorted(['info', 'authorizations', 'apiVersion', 'swaggerVersion', 'apis']))

        op = local_app.schema.apis['pet'].apis['updatePet']
        self.assertEqual(sorted(op._field_names_), sorted([
            'authorizations',
            'consumes',
            'defaultValue',
            'deprecated',
            'enum',
            'format',
            'items',
            'maximum',
            'method',
            'minimum',
            'nickname',
            'parameters',
            'path',
            'produces',
            'ref',
            'responseMessages',
            'type',
            'uniqueItems'
        ]))

        chd = local_app.schema._children_
        self.assertEqual(len(chd), 5)
        self.assertEqual(set(['user', 'pet', 'store']), set([c[0] for c in chd if isinstance(c[1], Resource)]))
Ejemplo n.º 22
0
 def setUp(self):
     self.app = SwaggerApp._create_(get_test_data_folder(version='1.2', which='err'))
Ejemplo n.º 23
0
from pyswagger import SwaggerApp, SwaggerSecurity
from ..utils import get_test_data_folder
import unittest


app = SwaggerApp._create_(get_test_data_folder(version='1.2', which='simple_auth')) 


class BasicAuthAndApiKeyTestCase(unittest.TestCase):
    """ test cases for authorzation related """

    def setUp(self):
        self.s = SwaggerSecurity(app)
        self.s.update_with('simple_key', '123456')
        self.s.update_with('simple_basic', ('mission', '123123'))
        self.s.update_with('simple_basic2', ('qoo', '456456'))
        self.s.update_with('simple_key2', '789789')

    def test_deleteUser(self):
        """ basic auth """
        req, _ = app.op['deleteUser'](username='******')
        self.s(req).prepare()

        self.assertTrue('Authorization' in req.header)
        self.assertEqual(req.header['Authorization'], 'Basic bWlzc2lvbjoxMjMxMjM=')

    def test_getUserByName(self):
        """ api key, passed by query """
        req, _ = app.op['getUserByName'](username='******')
        self.s(req).prepare()
Ejemplo n.º 24
0
from pyswagger import SwaggerApp
from .utils import get_test_data_folder
from ..primitives import Model, Array, Void
from pyswagger.io import SwaggerRequest
import unittest


app = SwaggerApp._create_(get_test_data_folder(version='1.2', which='wordnik')) 


class SwaggerRequest_Pet_TestCase(unittest.TestCase):
    """ test SwaggerRequest from Operation's __call__ """

    def test_updatePet(self):
        """ Pet.updatePet """
        req, _ = app.op['updatePet'](body=dict(id=1, name='Mary', category=dict(id=1, name='dog')))
        req.prepare()

        self.assertEqual(req.method, 'PUT')
        self.assertEqual(req.header, {'Content-Type': 'application/json', 'Accept': 'application/json'})
        self.assertEqual(req.url, 'http://petstore.swagger.wordnik.com/api/pet')
        self.assertEqual(req.query, {})

        m = req._p['body']['body']
        self.assertTrue(isinstance(m, Model))
        self.assertEqual(m.id, 1)
        self.assertEqual(m.name, 'Mary')
        self.assertTrue(isinstance(m.category, Model))
        self.assertEqual(m.category.id, 1)
        self.assertEqual(m.category.name, 'dog')
Ejemplo n.º 25
0
 def setUpClass(kls):
     kls.app = SwaggerApp._create_(get_test_data_folder(version='2.0', which=os.path.join('schema', 'additionalProperties')))
Ejemplo n.º 26
0
from pyswagger import SwaggerApp
from .utils import get_test_data_folder
from ..primitives import Model, Array, Void
from pyswagger.io import SwaggerRequest
import unittest

app = SwaggerApp._create_(get_test_data_folder(version='1.2', which='wordnik'))


class SwaggerRequest_Pet_TestCase(unittest.TestCase):
    """ test SwaggerRequest from Operation's __call__ """
    def test_updatePet(self):
        """ Pet.updatePet """
        req, _ = app.op['updatePet'](
            body=dict(id=1, name='Mary', category=dict(id=1, name='dog')))
        req.prepare()

        self.assertEqual(req.method, 'PUT')
        self.assertEqual(req.header, {
            'Content-Type': 'application/json',
            'Accept': 'application/json'
        })
        self.assertEqual(req.url,
                         'http://petstore.swagger.wordnik.com/api/pet')
        self.assertEqual(req.query, {})

        m = req._p['body']['body']
        self.assertTrue(isinstance(m, Model))
        self.assertEqual(m.id, 1)
        self.assertEqual(m.name, 'Mary')
        self.assertTrue(isinstance(m.category, Model))
Ejemplo n.º 27
0
 def setUpClass(kls):
     kls.app = SwaggerApp._create_(
         get_test_data_folder(version="2.0", which=os.path.join("schema", "additionalProperties"))
     )
Ejemplo n.º 28
0
 def setUpClass(kls):
     kls.app = SwaggerApp._create_(folder)
Ejemplo n.º 29
0
from pyswagger import SwaggerApp
from pyswagger.contrib.client.requests import Client
from pyswagger.primitives import Model
from ..utils import get_test_data_folder
import unittest
import httpretty
import json
import pytest
import sys


app = SwaggerApp._create_(get_test_data_folder(version='1.2', which='model_subtypes')) 
client = Client()

u_mission = dict(id=1, username='******', password='******')
uwi_mary = dict(id=2, username='******', password='******', email='*****@*****.**', phone='123')
uwi_kevin = dict(id=3, username='******')


@pytest.mark.skipif(sys.version_info[:2] >= (3, 3), reason='httpretty corrupt in python3')
class ModelInteritanceTestCase(unittest.TestCase):
    """ test cases for model inheritance """

    @httpretty.activate
    def test_inheritantce_full(self):
        """ init a Model with every property along
        the inheritance path.
        """
        httpretty.register_uri(
            httpretty.GET, 'http://petstore.swagger.wordnik.com/api/user/mary',
            status=200,
Ejemplo n.º 30
0
 def setUpClass(kls):
     kls.app = SwaggerApp._create_(
         get_test_data_folder(version='1.2', which='model_subtypes'))
Ejemplo n.º 31
0
from __future__ import absolute_import
from pyswagger import SwaggerApp
from pyswagger.contrib.client.requests import Client
from ...utils import get_test_data_folder
from ....primitives import Model, Array
import unittest
import httpretty
import json
import six


app = SwaggerApp._create_(get_test_data_folder(version="1.2", which="wordnik"))
client = Client()


pet_Tom = dict(id=1, name="Tom", tags=[dict(id=0, name="available"), dict(id=1, name="sold")])
pet_Qoo = dict(id=2, name="Qoo", tags=[dict(id=0, name="available")])
pet_Sue = dict(id=3, name="Sue", tags=[dict(id=0, name="available")])
pet_Kay = dict(id=4, name="Kay", category=dict(id=2, name="cat"), status="available", photoUrls=None, tags=None)
pet_QQQ = dict(id=1, name="QQQ", category=dict(id=1, name="dog"), tags=None, status=None)


@httpretty.activate
class RequestsClient_Pet_TestCase(unittest.TestCase):
    """ test SwaggerClient implemented by requests """

    def test_updatePet(self):
        """ Pet.updatePet """
        httpretty.register_uri(httpretty.PUT, "http://petstore.swagger.wordnik.com/api/pet", status=200)

        resp = client.request(app.op["updatePet"](body=pet_QQQ))
Ejemplo n.º 32
0
 def setUpClass(kls):
     kls.app = SwaggerApp._create_(get_test_data_folder(
         version='2.0',
         which=os.path.join('resolve', 'deref')
     ))
Ejemplo n.º 33
0
    def test_http_getter(self):
        """ make sure HTTPGetter works """

        folder = get_test_data_folder(version='1.2', which='wordnik')
        resource_list = user = pet = store = None

        with open(os.path.join(folder, 'resource_list.json')) as f:
            resource_list = f.read()

        with open(os.path.join(folder, 'user.json')) as f:
            user = f.read()

        with open(os.path.join(folder, 'pet.json')) as f:
            pet = f.read()

        with open(os.path.join(folder, 'store.json')) as f:
            store = f.read()

        httpretty.register_uri(
            httpretty.GET, 'http://petstore.swagger.wordnik.com/api/api-docs',
            status=200,
            body=resource_list
            )

        httpretty.register_uri(
            httpretty.GET, 'http://petstore.swagger.wordnik.com/api/api-docs/user',
            status=200,
            body=user
            )

        httpretty.register_uri(
            httpretty.GET, 'http://petstore.swagger.wordnik.com/api/api-docs/pet',
            status=200,
            body=pet
            )

        httpretty.register_uri(
            httpretty.GET, 'http://petstore.swagger.wordnik.com/api/api-docs/store',
            status=200,
            body=store
            )

        local_app = SwaggerApp._create_('http://petstore.swagger.wordnik.com/api/api-docs')

        self.assertEqual(sorted(local_app.raw._field_names_), sorted(['info', 'authorizations', 'apiVersion', 'swaggerVersion', 'apis']))

        op = local_app.raw.apis['pet'].apis['updatePet']
        self.assertEqual(sorted(op._field_names_), sorted([
            'authorizations',
            'consumes',
            'defaultValue',
            'deprecated',
            'enum',
            'format',
            'items',
            'maximum',
            'method',
            'minimum',
            'nickname',
            'parameters',
            'produces',
            '$ref',
            'responseMessages',
            'type',
            'uniqueItems',
            'summary',
            'notes'
        ]))
Ejemplo n.º 34
0
 def setUpClass(kls):
     kls.app = SwaggerApp._create_(
         get_test_data_folder(version='2.0',
                              which=os.path.join('schema',
                                                 'additionalProperties')))
Ejemplo n.º 35
0
from pyswagger import SwaggerApp
from pyswagger.contrib.client.requests import Client
from pyswagger.primitives import Model
from ..utils import get_test_data_folder
import unittest
import httpretty
import json
import pytest
import sys

app = SwaggerApp._create_(
    get_test_data_folder(version='1.2', which='model_subtypes'))
client = Client()

u_mission = dict(id=1, username='******', password='******')
uwi_mary = dict(id=2,
                username='******',
                password='******',
                email='*****@*****.**',
                phone='123')
uwi_kevin = dict(id=3, username='******')


@pytest.mark.skipif(sys.version_info[:2] >= (3, 3),
                    reason='httpretty corrupt in python3')
class ModelInteritanceTestCase(unittest.TestCase):
    """ test cases for model inheritance """
    @httpretty.activate
    def test_inheritantce_full(self):
        """ init a Model with every property along
        the inheritance path.
Ejemplo n.º 36
0
 def setUpClass(kls):
     kls.app = SwaggerApp._create_(
         get_test_data_folder(version='2.0',
                              which=os.path.join('schema', 'model')))
Ejemplo n.º 37
0
 def setUpClass(kls):
     kls.app = SwaggerApp._create_(
         get_test_data_folder(version='2.0', which='patch'))
Ejemplo n.º 38
0
from pyswagger import SwaggerApp, SwaggerSecurity
from pyswagger.contrib.client.requests import Client
from pyswagger.utils import jp_compose

# load Swagger resource file into SwaggerApp object
app = SwaggerApp._create_('http://petstore.swagger.io/v2/swagger.json')

auth = SwaggerSecurity(app)
auth.update_with('api_key', '12312312312312312313q')  # api key
auth.update_with('petstore_auth', '12334546556521123fsfss')  # oauth2

# init swagger client
client = Client(auth)

# a dict is enough for representing a Model in Swagger
pet_Tom = dict(id=1, name='Tom', photoUrls=['http://test'])
# a request to create a new pet
client.request(app.op['addPet'](body=pet_Tom))

# - access an Operation object via SwaggerApp.op when operationId is defined
# - a request to get the pet back
pet = client.request(app.op['getPetById'](petId=1)).data
assert pet.id == 1
assert pet.name == 'Tom'

# new ways to get Operation object corresponding to 'getPetById'.
# 'jp_compose' stands for JSON-Pointer composition
pet = client.request(
    app.resolve(jp_compose('/pet/{petId}', base='#/paths')).get(petId=1)).data
assert pet.id == 1