Beispiel #1
0
    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,
        }]
Beispiel #2
0
 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')
Beispiel #3
0
 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
Beispiel #4
0
 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')
Beispiel #5
0
 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
Beispiel #6
0
 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'
Beispiel #7
0
 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'
Beispiel #8
0
 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'
Beispiel #9
0
 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'