def test_add_resource_context_passing_classes(self, app): with add_resource_context(app) as route: route('/articles/', views.ArticleResource()) route('/articles/{pk}', views.ArticleList()) assert str(app.router['ArticleResource:get'].url_for()) == '/articles/' assert str(app.router['ArticleResource:post'].url_for()) == '/articles/'
def test_add_resource_context_passing_classes_with_prefix(self, app): with add_resource_context(app, name_prefix='articles') as route: route('/articles/', views.ArticleResource()) route('/articles/{pk}', views.ArticleList()) assert str(app.router['articles.ArticleResource:get'].url_for()) == '/articles/' assert str(app.router['articles.ArticleResource:post'].url_for()) == '/articles/' assert str(app.router['articles.ArticleList:post'].url_for( pk='42')) == '/articles/42' # noqa
def test_add_resource_context_passing_classes_with_prefix(self, app): with add_resource_context(app, name_prefix='articles') as route: route('/articles/', views.ArticleResource()) route('/articles/{pk}', views.ArticleList()) assert app.router['articles.ArticleResource:get'].url() == '/articles/' assert app.router['articles.ArticleResource:post'].url( ) == '/articles/' assert app.router['articles.ArticleList:post'].url( parts={'pk': 42}) == '/articles/42'