From b7f2674b4e486b694c747d3d894c1924c88eea76 Mon Sep 17 00:00:00 2001
From: Andreas <andreasv@fsmpi.rwth-aachen.de>
Date: Sat, 2 Dec 2017 22:25:46 +0100
Subject: [PATCH] added a test for adding a new course

---
 tests.py | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/tests.py b/tests.py
index b322a09..dab2a26 100755
--- a/tests.py
+++ b/tests.py
@@ -8,15 +8,12 @@ import flask
 from flask import url_for
 
 class VideoTestCase(unittest.TestCase):
-	@classmethod
-	def setUpClass(cls):
-		server.app.testing = True
-	
 	@classmethod
 	def tearDownClass(cls):
 		os.unlink(server.app.config['SQLITE_DB'])
 	
 	def setUp(self):
+		server.app.testing = True
 		self.app = server.app.test_client()
 
 	def test_index(self):
@@ -61,6 +58,18 @@ class VideoTestCase(unittest.TestCase):
 			assert r.status_code == 302
 			assert '<a href="/">' in r.data.decode()
 	
+	def test_edit(self):
+		with self.app as c:
+			with c.session_transaction() as sess:
+				sess['user'] = {'name': 'videoag', '_csrf_token': 'asd', 'dbid': 72}
+				sess['_csrf_token'] = 'asd'
+			# add course
+			r = c.get('/internal/new/courses', data={'title': 'Neue Veranstaltung totalyrandomcrap', 'responsible': 'foo', 'handle': '2r5sQDFCRT3DG', '_csrf_token': 'asd'})
+			assert r.status_code == 200
+			r = self.app.get('/courses')
+			assert r.status_code == 200
+			assert 'Neue Veranstaltung totalyrandomcrap' in r.data.decode() and '2r5sQDFCRT3DG' in r.data.decode()
+
 	def test_legacyurl(self):
 		with self.app as c:
 			r = self.app.get('/site/feed.php?newcourses')
-- 
GitLab