def test_it_does_not_modify_context_if_accept_not_set( self, pyramid_request, testview): fake_context = mock.Mock() validate_media_types(testview)(fake_context, pyramid_request) context, _ = testview.call_args[0] assert context == fake_context
def test_it_does_not_modify_context_if_accept_not_set( self, pyramid_request, testview ): fake_context = mock.Mock() validate_media_types(testview)(fake_context, pyramid_request) context, _ = testview.call_args[0] assert context == fake_context
def test_it_does_not_modify_context_if_any_accept_values_ok( self, pyramid_request, testview): # At least one of these is valid pyramid_request.accept = MIMEAccept("application/json, foo/bar") fake_context = mock.Mock() validate_media_types(testview)(fake_context, pyramid_request) context, _ = testview.call_args[0] assert context == fake_context
def test_it_replaces_context_with_406_if_accept_set_and_invalid( self, pyramid_request, testview): # None of these is valid pyramid_request.accept = create_accept_header( "application/something+json, foo/bar") fake_context = mock.Mock() validate_media_types(testview)(fake_context, pyramid_request) context, _ = testview.call_args[0] assert isinstance(context, HTTPNotAcceptable)
def test_it_replaces_context_with_415_if_accept_set_and_invalid( self, pyramid_request, testview ): # None of these is valid pyramid_request.accept = MIMEAccept("application/something+json, foo/bar") fake_context = mock.Mock() validate_media_types(testview)(fake_context, pyramid_request) context, _ = testview.call_args[0] assert isinstance(context, HTTPUnsupportedMediaType)
def test_it_does_not_modify_context_if_any_accept_values_ok( self, pyramid_request, testview ): # At least one of these is valid pyramid_request.accept = MIMEAccept("application/json, foo/bar") fake_context = mock.Mock() validate_media_types(testview)(fake_context, pyramid_request) context, _ = testview.call_args[0] assert context == fake_context
def test_it_replaces_context_with_415_if_accept_set_and_invalid( self, pyramid_request, testview): # None of these is valid pyramid_request.accept = MIMEAccept( "application/something+json, foo/bar") fake_context = mock.Mock() validate_media_types(testview)(fake_context, pyramid_request) context, _ = testview.call_args[0] assert isinstance(context, HTTPUnsupportedMediaType)
def test_it_calls_wrapped_view_function(self, pyramid_request, testview): validate_media_types(testview)(None, pyramid_request) assert testview.called
def test_it_calls_wrapped_view_function(self, pyramid_request, testview): validate_media_types(testview)(None, pyramid_request) assert testview.called