Ejemplo n.º 1
0
 def test_init(self):
     route = 'something'
     endpoint = 'endpoint'
     api = apimethod(route=route, endpoint=endpoint, another=True, and_another=False)
     self.assertEqual(route, api.route)
     self.assertEqual(endpoint, api.endpoint)
     self.assertDictEqual(dict(another=True, and_another=False, no_pks=False, methods=['GET']), api.options)
Ejemplo n.º 2
0
 def test_init(self):
     route = 'something'
     endpoint = 'endpoint'
     api = apimethod(route=route, endpoint=endpoint, another=True, and_another=False)
     self.assertEqual(route, api.route)
     self.assertEqual(endpoint, api.endpoint)
     self.assertDictEqual(dict(another=True, and_another=False, no_pks=False, methods=['GET']), api.options)
Ejemplo n.º 3
0
    def test_call(self):
        route = 'something'
        endpoint = 'endpoint'

        def fake(*args, **kwargs):
            return mock.MagicMock()

        api = apimethod(route=route, endpoint=endpoint)
        wrapped = api(fake)
        self.assertTrue(getattr(wrapped, '__rest_route__', False))
        routes = getattr(wrapped, 'routes')
        self.assertIsInstance(routes, list)
        self.assertEqual(len(routes), 1)
        self.assertEqual((route, endpoint, dict(methods=['GET'], no_pks=False)), routes[0])
        api2 = apimethod(route='another', endpoint='thing')

        wrapped = api2(wrapped)
        routes = getattr(wrapped, 'routes')
        self.assertEqual(len(routes), 2)
        self.assertEqual(('another', 'thing', dict(methods=['GET'], no_pks=False)), routes[1])
Ejemplo n.º 4
0
    def test_call(self):
        route = 'something'
        endpoint = 'endpoint'

        def fake(*args, **kwargs):
            return mock.MagicMock()

        api = apimethod(route=route, endpoint=endpoint)
        wrapped = api(fake)
        self.assertTrue(getattr(wrapped, '__rest_route__', False))
        routes = getattr(wrapped, 'routes')
        self.assertIsInstance(routes, list)
        self.assertEqual(len(routes), 1)
        self.assertEqual((route, endpoint, dict(methods=['GET'], no_pks=False)), routes[0])
        api2 = apimethod(route='another', endpoint='thing')

        wrapped = api2(wrapped)
        routes = getattr(wrapped, 'routes')
        self.assertEqual(len(routes), 2)
        self.assertEqual(('another', 'thing', dict(methods=['GET'], no_pks=False)), routes[1])