def test_it_adds_api_links_to_registry(self, pyramid_config, view, link_name, description, request_method, expected_method): kwargs = {} if request_method: kwargs['request_method'] = request_method views.add_api_view(pyramid_config, view=view, link_name=link_name, description=description, route_name=link_name, **kwargs) assert pyramid_config.registry.api_links == [{ 'name': link_name, 'description': description, 'method': expected_method, 'route_name': link_name, }]
def test_it_adds_all_request_methods_when_not_defined( self, pyramid_config, view): views.add_api_view(pyramid_config, view) (_, kwargs) = pyramid_config.add_view.call_args assert kwargs['request_method'] == ('DELETE', 'GET', 'HEAD', 'POST', 'PUT', 'OPTIONS')
def test_it_allows_decorator_override(self, pyramid_config, view): decorator = mock.Mock() views.add_api_view(pyramid_config, view, decorator=decorator) (_, kwargs) = pyramid_config.add_view.call_args assert kwargs['decorator'] == decorator
def test_it_adds_OPTIONS_to_allowed_request_methods( self, pyramid_config, view): views.add_api_view(pyramid_config, view, request_method='DELETE') (_, kwargs) = pyramid_config.add_view.call_args assert kwargs['request_method'] == ('DELETE', 'OPTIONS')
def test_it_sets_cors_decorator(self, pyramid_config, view): views.add_api_view(pyramid_config, view) (_, kwargs) = pyramid_config.add_view.call_args assert kwargs['decorator'] == views.cors_policy
def test_it_allows_renderer_setting_override(self, pyramid_config, view): views.add_api_view(pyramid_config, view, renderer='xml') (_, kwargs) = pyramid_config.add_view.call_args assert kwargs['renderer'] == 'xml'
def test_it_sets_renderer_setting(self, pyramid_config, view): views.add_api_view(pyramid_config, view) (_, kwargs) = pyramid_config.add_view.call_args assert kwargs['renderer'] == 'json'
def test_it_allows_accept_setting_override(self, pyramid_config, view): views.add_api_view(pyramid_config, view, accept='application/xml') (_, kwargs) = pyramid_config.add_view.call_args assert kwargs['accept'] == 'application/xml'
def test_it_sets_accept_setting(self, pyramid_config, view): views.add_api_view(pyramid_config, view) (_, kwargs) = pyramid_config.add_view.call_args assert kwargs['accept'] == 'application/json'