forked from bartaz/snapcraft-flask
-
Notifications
You must be signed in to change notification settings - Fork 1
/
tests.py
executable file
·37 lines (25 loc) · 1.01 KB
/
tests.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
#! /usr/bin/env python3
import app
import unittest
class WebAppTestCase(unittest.TestCase):
def setUp(self):
self.app = app.app.test_client()
self.app.testing = True
def test_homepage(self):
response = self.app.get('/')
assert response.status_code == 200
assert "Ubuntu and Canonical are registered" in str(response.data)
def test_redirect_to_add_slash(self):
response = self.app.get('/canonical-livepatch')
location = response.headers.get('Location')
assert response.status_code in (301, 302)
assert location == "http://localhost/canonical-livepatch/"
def test_canonical_livepatch_snap(self):
response = self.app.get('/canonical-livepatch/')
assert response.status_code == 200
def test_non_existent_snap(self):
response = self.app.get('/non-existent-snap/')
assert response.status_code == 404
assert "Snap not found" in str(response.data)
if __name__ == '__main__':
unittest.main()