diff --git a/ivatar/test_views.py b/ivatar/test_views.py index dbed347..cc18515 100644 --- a/ivatar/test_views.py +++ b/ivatar/test_views.py @@ -61,5 +61,8 @@ class Tester(TestCase): # pylint: disable=too-many-public-methods """ Test incorrect digest """ - response = self.client.get('/avatar/%s' % 'x'*65) - self.assertEqual(response.status_code, 200, 'no 200 ok?') + response = self.client.get('/avatar/%s' % 'x'*65, follow=True) + self.assertRedirects( + response=response, + expected_url='/static/img/deadbeef.png', + msg_prefix='Why does an invalid hash not redirect to deadbeef?') diff --git a/ivatar/urls.py b/ivatar/urls.py index a7a4870..7ba926b 100644 --- a/ivatar/urls.py +++ b/ivatar/urls.py @@ -24,11 +24,7 @@ urlpatterns = [ # pylint: disable=invalid-name url(r'avatar/$', AvatarImageView.as_view(), name='avatar_view'), url( r'avatar/(?P\w*)', - TemplateView.as_view( - template_name='error.html', - extra_context={ - 'errormessage': 'Incorrect digest length', - })), + RedirectView.as_view(url='/static/img/deadbeef.png'), name='invalid_hash'), url( r'gravatarproxy/(?P\w*)', GravatarProxyView.as_view(), name='gravatarproxy'),