From f5f741a5c228894c4f2412da3140fb3c20a98c75 Mon Sep 17 00:00:00 2001 From: cookietime--yay Date: Mon, 4 Mar 2019 22:46:42 +0100 Subject: [PATCH] Add more test stubs for frontend. --- .../tests/configs/webapptestconfig.toml | 20 ++++++++++++++++ .../WebApplicationLogin.py} | 23 ++++++++----------- .../webapptests/WebApplicationRegister.py | 16 +++++++++++++ 3 files changed, 46 insertions(+), 13 deletions(-) create mode 100644 ticketfrei/tests/configs/webapptestconfig.toml rename ticketfrei/tests/{WebApplicationTest.py => webapptests/WebApplicationLogin.py} (56%) create mode 100644 ticketfrei/tests/webapptests/WebApplicationRegister.py diff --git a/ticketfrei/tests/configs/webapptestconfig.toml b/ticketfrei/tests/configs/webapptestconfig.toml new file mode 100644 index 0000000..ff54708 --- /dev/null +++ b/ticketfrei/tests/configs/webapptestconfig.toml @@ -0,0 +1,20 @@ +[twitter] +# You get those keys when you follow these steps: +# https://developer.twitter.com/en/docs/basics/authentication/guides/access-tokens +consumer_key = "your_consumer_key" +consumer_secret = "your_consumer_secret" + +[web] +host = "0.0.0.0" # will be used by bottle as a host. +port = 80 +contact = "b3yond@riseup.net" + +[mail] +mbox_user = "root" + +[database] +db_path = "/var/ticketfrei/db.sqlite" + +[log] +log_frontend = "/var/ticketfrei/frontend.log" +log_backend = "/var/log/ticketfrei/backend.log" diff --git a/ticketfrei/tests/WebApplicationTest.py b/ticketfrei/tests/webapptests/WebApplicationLogin.py similarity index 56% rename from ticketfrei/tests/WebApplicationTest.py rename to ticketfrei/tests/webapptests/WebApplicationLogin.py index 04517ed..3f9117f 100644 --- a/ticketfrei/tests/WebApplicationTest.py +++ b/ticketfrei/tests/webapptests/WebApplicationLogin.py @@ -2,25 +2,22 @@ from webtest import TestApp import unittest import frontend +app = TestApp(frontend.application) + class TestLogin(unittest.TestCase): + def setUp(self): + pass + + def tearDown(self): + pass + def test_login_not_registered(self): - app = TestApp(frontend.application) request = app.post('/login', {'email': '', 'pass': ''}, expect_errors=True) self.assertEqual(401, request.status_code) -class TestRegister(unittest.TestCase): - - def test_register(self): - app = TestApp(frontend.application) + def test_login_registered(self): request = app.post('/register', {'email': 'foo@abc.de', 'pass': 'bar', 'pass-repeat': 'bar', 'city': 'testcity'}, expect_errors=True) + request = app.post('/login', {'email': 'foor@abc.de', 'pass': 'bar'}, expect_errors=False) self.assertEqual(200, request.status_code) - def test_getRoot(self): - app = TestApp(frontend.application) - request = app.get('/') - self.assertEqual(200, request.status_code) - - -if __name__ == '__main__': - unittest.main() diff --git a/ticketfrei/tests/webapptests/WebApplicationRegister.py b/ticketfrei/tests/webapptests/WebApplicationRegister.py new file mode 100644 index 0000000..bc88bb2 --- /dev/null +++ b/ticketfrei/tests/webapptests/WebApplicationRegister.py @@ -0,0 +1,16 @@ +from webtest import TestApp +import unittest +import frontend + +app = TestApp(frontend.application) + +class TestRegister(unittest.TestCase): + + def test_register(self): + request = app.post('/register', {'email': 'foo@abc.de', 'pass': 'bar', 'pass-repeat': 'bar', 'city': 'testcity'}, expect_errors=True) + self.assertEqual(200, request.status_code) + + def test_getRoot(self): + request = app.get('/') + self.assertEqual(200, request.status_code) +