From 57ac19b347646b1aea9b325a72c9cb635a99d7e5 Mon Sep 17 00:00:00 2001 From: anastasia Date: Thu, 17 Aug 2017 17:13:21 -0400 Subject: [PATCH] add - test, testing message appearance on pdf + mobile --- .../templates/archive/download_to_view_pdf.html | 2 +- perma_web/perma/tests/test_views_common.py | 13 ++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/perma_web/perma/templates/archive/download_to_view_pdf.html b/perma_web/perma/templates/archive/download_to_view_pdf.html index 5e4fbcb3f..f56811008 100644 --- a/perma_web/perma/templates/archive/download_to_view_pdf.html +++ b/perma_web/perma/templates/archive/download_to_view_pdf.html @@ -1,6 +1,6 @@ {% with request.META.HTTP_REFERER as referer %}
-

Perma.cc can't display this file type on mobile but you can view or download the archived file by clicking below.

+

Perma.cc can't display this file type on mobile, but you can view or download the archived file by clicking below.

File type {{mime_type}}

View/Download File
diff --git a/perma_web/perma/tests/test_views_common.py b/perma_web/perma/tests/test_views_common.py index 1ea1f66ea..3f1b14a16 100644 --- a/perma_web/perma/tests/test_views_common.py +++ b/perma_web/perma/tests/test_views_common.py @@ -1,7 +1,7 @@ from django.conf import settings from django.core import mail from django.core.urlresolvers import reverse -from django.test import override_settings +from django.test import override_settings, Client from perma.urls import urlpatterns from perma.models import Registrar @@ -54,6 +54,17 @@ def test_dark_archive(self): response = self.get('single_linky', reverse_kwargs={'kwargs': {'guid': 'ABCD-0001'}}) self.assertIn("This record is private.", response.content) + def test_redirect_to_download(self): + # Give user option to download to view pdf if on mobile + client = Client(HTTP_USER_AGENT='Mozilla/5.0 (iPhone; CPU iPhone OS 6_1_4 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10B350 Safari/8536.25') + response = client.get(reverse('single_linky', kwargs={'guid': '7CF8-SS4G'})) + self.assertIn("Perma.cc can\'t display this file type on mobile", response.content) + + # If not on mobile, display link as normal + client = Client(HTTP_USER_AGENT='Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/601.7.7 (KHTML, like Gecko) Version/9.1.2 Safari/601.7.7') + response = client.get(reverse('single_linky', kwargs={'guid': '7CF8-SS4G'})) + self.assertNotIn("Perma.cc can\'t display this file type on mobile", response.content) + def test_deleted(self): response = self.get('single_linky', reverse_kwargs={'kwargs': {'guid': 'ABCD-0003'}}) self.assertIn("This record has been deleted.", response.content)