forked from silviolleite/django-pwa
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest_view.py
59 lines (46 loc) · 1.73 KB
/
test_view.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
from django.test import TestCase
from django.shortcuts import resolve_url as r
class ServiceWorkerTest(TestCase):
def setUp(self):
self.response = self.client.get(r('serviceworker'))
def test_get(self):
"""GET /serviceworker.js Should return status code 200"""
self.assertEqual(200, self.response.status_code)
class ManifestTest(TestCase):
def setUp(self):
self.response = self.client.get(r('manifest'), format='json')
def test_get(self):
"""GET /manifest.json Should return status code 200"""
self.assertEqual(self.response.status_code, 200)
def test_content_type_json(self):
"""The content type Must be JSON"""
self.assertEqual(self.response['content-type'], 'application/json')
def test_template(self):
"""Must have the template manifest.json"""
self.assertTemplateUsed(self.response, 'manifest.json')
def test_manifest_contains(self):
"""Must be the attributes to manitesf.json"""
contents = [
'"name":',
'"short_name":',
'"description":',
'"start_url":',
'"display":',
'"scope":',
'"background_color":',
'"theme_color":',
'"orientation":',
'"icons":',
'"dir":',
'"lang":',
'"status_bar":'
]
for expected in contents:
with self.subTest():
self.assertContains(self.response, expected)
class OfflineTest(TestCase):
def setUp(self):
self.response = self.client.get(r('offline'))
def test_get(self):
"""GET /offline Should return status code 200"""
self.assertEqual(200, self.response.status_code)