Skip to content

Commit

Permalink
add - test, testing message appearance on pdf + mobile
Browse files Browse the repository at this point in the history
  • Loading branch information
anastasia committed Aug 17, 2017
1 parent 085f13f commit 57ac19b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{% with request.META.HTTP_REFERER as referer %}
<div class="record-message">
<p class="record-message-primary">Perma.cc can't display this file type on mobile but you can view or download the archived file by clicking below.</p>
<p class="record-message-primary">Perma.cc can't display this file type on mobile, but you can view or download the archived file by clicking below.</p>
<p class="record-message-secondary">File type {{mime_type}}</p>
<a class="btn btn-large btn-info" target="_blank" href="{{capture.url}}">View/Download File</a>
<div>
Expand Down
13 changes: 12 additions & 1 deletion perma_web/perma/tests/test_views_common.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 57ac19b

Please sign in to comment.