# coding: utf-8 from restify.api import Api from yaat_examples.api.resources import ModelExampleResource, ModelComputedExampleResource, StatefulColumns, \ StatefulInit, Limited api = Api(api_name='example') api.register(regex='model_example/$', resource=ModelExampleResource) api.register(regex='model_computed_example/$', resource=ModelComputedExampleResource) api.register(regex='limited/$', resource=Limited) api.register(regex='stateful_columns/$', resource=StatefulColumns) api.register(regex='stateful_init/$', resource=StatefulInit)
from restify.api import Api from bangoo.content.api import resources as content_resources from bangoo.navigation.api import resources as navigation_resources api = Api(api_name='v1') api.register(regex='content/(?P<menu_id>(\d+|new))/$', resource=content_resources.ContentResource) api.register(regex='navigation/(?P<menu_id>(\d+|new))/$', resource=navigation_resources.MenuResource)
# coding: utf-8 from restify.api import Api from yaat_examples.api.resources import ModelExampleResource, ModelComputedExampleResource, Stateful api = Api(api_name='example') api.register(regex='model_example/$', resource=ModelExampleResource) api.register(regex='model_computed_example/$', resource=ModelComputedExampleResource) api.register(regex='stateful/$', resource=Stateful)
def test_api_register_resource(self): api = Api() api.register(r'first/$', CustomResource) self.assertEqual(len(api.urls), 1) self.assertIsInstance(api.urls[0], RegexURLPattern) self.assertEqual(api.urls[0].name, 'example')
def test_api_urls_empty(self): api = Api() self.assertEqual(len(api.urls), 0) self.assertIsInstance(api.urls, list)
def test_api_naming(self): api = Api() self.assertEqual(api.name, 'v1') api = Api(api_name='v2') self.assertEqual(api.name, 'v2')