From 050e641bb0dd8820b758efaeb348bbd35b49f251 Mon Sep 17 00:00:00 2001
From: cookietime--yay <cookietime--yay@users.noreply.github.com>
Date: Mon, 4 Mar 2019 18:49:12 +0100
Subject: [PATCH] Add initial tests for Web Interface.

---
 tests/WebApplicationTest.py |  26 ++++++++++++
 tests/db.sqlite             | Bin 0 -> 180224 bytes
 tests/errors.log            |  77 ++++++++++++++++++++++++++++++++++++
 3 files changed, 103 insertions(+)
 create mode 100644 tests/WebApplicationTest.py
 create mode 100644 tests/db.sqlite
 create mode 100644 tests/errors.log

diff --git a/tests/WebApplicationTest.py b/tests/WebApplicationTest.py
new file mode 100644
index 0000000..cc48076
--- /dev/null
+++ b/tests/WebApplicationTest.py
@@ -0,0 +1,26 @@
+from webtest import TestApp
+import unittest
+from ticketfrei import frontend
+
+class TestLogin(unittest.TestCase):
+
+    def test_login_not_registered(self):
+        app = TestApp(frontend.application)
+        request = app.post('/login', {'email': 'foo@abc.de', 'pass': 'bar'}, expect_errors=True)
+        self.assertEqual(request.status_code, 401)
+
+class TestRegister(unittest.TestCase):
+
+    def test_register(self):
+        app = TestApp(frontend.application)
+        request = app.post('/register', {'email': 'foo@abc.de', 'pass': 'bar', 'pass-repeat': 'bar', 'city': 'testcity'}, expect_errors=True)
+        self.assertEqual(request.status_code, 201)
+
+    def test_getRoot(self):
+        app = TestApp(frontend.application)
+        request = app.get('/')
+        self.assertEqual(request.status_code, 200)
+
+
+if __name__ == '__main__':
+    unittest.main()
diff --git a/tests/db.sqlite b/tests/db.sqlite
new file mode 100644
index 0000000000000000000000000000000000000000..8e9d3f273ff4b477f13a9ed97b12ffbcf820f5f4
GIT binary patch
literal 180224
zcmeI(%}*QY9l&u9FXI3)Bms6pvMj@r7hFhLZ-kUIT5Sn62rV%SF>Rx*WEq&U(}11z
z45izuTCHJo>Oas+)l1cT&plOY4?VQ%rT;?JOVwMe_R@JZe(;RLAWt=xzK+25GtWGJ
z{P{ie%=1E?Z?5a6rhdO#J1m>(!_>8uB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P3w<agiAT1Q0*~0R#|0009ILKmdWR6kz|qE5k;m5kLR|
z1Q0*~0R#|0009ILh$O)Ne<Ut4BY*$`2q1s}0tg_000Iag(3Jx0|955Bs5AlyAb<b@
z2q1s}0tg_000NN&*#D2jMP>vLKmY**5I_I{1Q0*~0R*~Ifc^ij3>%e3009ILKmY**
z5I_I{1Q0+Vk^uYvk+{f=00IagfB*srAb<b@2q1t!R|>HI-<4sb(g+}c00IagfB*sr
zAb<b@2t*QK{vU~p%m^TW00IagfB*srAb<b@2y~?YfB)Z=VWZLrAb<b@2q1s}0tg_0
j00Ia^5@7#75*L{fKmY**5I_I{1Q0*~0R#}}N`e0YsYMMR

literal 0
HcmV?d00001

diff --git a/tests/errors.log b/tests/errors.log
new file mode 100644
index 0000000..5239b00
--- /dev/null
+++ b/tests/errors.log
@@ -0,0 +1,77 @@
+Could not send confirmation mail to foo@abc.de
+Traceback (most recent call last):
+  File "/home/kaese/Projekte/ticketfrei/ticketfrei/frontend.py", line 42, in register_post
+    link = url('confirm/' + city + '/%s' % db.user_token(email, password))
+  File "/home/kaese/Projekte/ticketfrei/ticketfrei/db.py", line 186, in user_token
+    return jwt.encode({
+AttributeError: module 'jwt' has no attribute 'encode'
+Could not send confirmation mail to foo@abc.de
+Traceback (most recent call last):
+  File "/home/kaese/Projekte/ticketfrei/ticketfrei/frontend.py", line 42, in register_post
+    link = url('confirm/' + city + '/%s' % db.user_token(email, password))
+  File "/home/kaese/Projekte/ticketfrei/ticketfrei/db.py", line 186, in user_token
+    return jwt.encode({
+AttributeError: module 'jwt' has no attribute 'encode'
+Could not send confirmation mail to foo@abc.de
+Traceback (most recent call last):
+  File "/home/kaese/Projekte/ticketfrei/ticketfrei/frontend.py", line 42, in register_post
+    link = url('confirm/' + city + '/%s' % db.user_token(email, password))
+  File "/home/kaese/Projekte/ticketfrei/ticketfrei/db.py", line 186, in user_token
+    return jwt.encode({
+AttributeError: module 'jwt' has no attribute 'encode'
+Could not send confirmation mail to foo@abc.de
+Traceback (most recent call last):
+  File "/home/kaese/Projekte/ticketfrei/ticketfrei/frontend.py", line 42, in register_post
+    link = url('confirm/' + city + '/%s' % db.user_token(email, password))
+  File "/home/kaese/Projekte/ticketfrei/ticketfrei/db.py", line 186, in user_token
+    return jwt.encode({
+AttributeError: module 'jwt' has no attribute 'encode'
+Could not send confirmation mail to foo@abc.de
+Traceback (most recent call last):
+  File "/home/kaese/Projekte/ticketfrei/ticketfrei/frontend.py", line 42, in register_post
+    link = url('confirm/' + city + '/%s' % db.user_token(email, password))
+  File "/home/kaese/Projekte/ticketfrei/ticketfrei/db.py", line 186, in user_token
+    return jwt.encode({
+AttributeError: module 'jwt' has no attribute 'encode'
+Could not send confirmation mail to foo@abc.de
+Traceback (most recent call last):
+  File "/home/kaese/Projekte/ticketfrei/ticketfrei/frontend.py", line 42, in register_post
+    link = url('confirm/' + city + '/%s' % db.user_token(email, password))
+  File "/home/kaese/Projekte/ticketfrei/ticketfrei/db.py", line 186, in user_token
+    return jwt.encode({
+AttributeError: module 'jwt' has no attribute 'encode'
+Could not send confirmation mail to foo@abc.de
+Traceback (most recent call last):
+  File "/home/kaese/Projekte/ticketfrei/ticketfrei/frontend.py", line 42, in register_post
+    link = url('confirm/' + city + '/%s' % db.user_token(email, password))
+  File "/home/kaese/Projekte/ticketfrei/ticketfrei/db.py", line 186, in user_token
+    return jwt.encode({
+AttributeError: module 'jwt' has no attribute 'encode'
+Could not send confirmation mail to foo@abc.de
+Traceback (most recent call last):
+  File "/home/kaese/Projekte/ticketfrei/ticketfrei/frontend.py", line 42, in register_post
+    link = url('confirm/' + city + '/%s' % db.user_token(email, password))
+  File "/home/kaese/Projekte/ticketfrei/ticketfrei/db.py", line 186, in user_token
+    return jwt.encode({
+AttributeError: module 'jwt' has no attribute 'encode'
+Could not send confirmation mail to foo@abc.de
+Traceback (most recent call last):
+  File "/home/kaese/Projekte/ticketfrei/ticketfrei/frontend.py", line 42, in register_post
+    link = url('confirm/' + city + '/%s' % db.user_token(email, password))
+  File "/home/kaese/Projekte/ticketfrei/ticketfrei/db.py", line 186, in user_token
+    return jwt.encode({
+AttributeError: module 'jwt' has no attribute 'encode'
+Could not send confirmation mail to foo@abc.de
+Traceback (most recent call last):
+  File "/home/kaese/Projekte/ticketfrei/ticketfrei/frontend.py", line 42, in register_post
+    link = url('confirm/' + city + '/%s' % db.user_token(email, password))
+  File "/home/kaese/Projekte/ticketfrei/ticketfrei/db.py", line 186, in user_token
+    return jwt.encode({
+AttributeError: module 'jwt' has no attribute 'encode'
+Could not send confirmation mail to foo@abc.de
+Traceback (most recent call last):
+  File "/home/kaese/Projekte/ticketfrei/ticketfrei/frontend.py", line 42, in register_post
+    link = url('confirm/' + city + '/%s' % db.user_token(email, password))
+  File "/home/kaese/Projekte/ticketfrei/ticketfrei/db.py", line 186, in user_token
+    return jwt.encode({
+AttributeError: module 'jwt' has no attribute 'encode'