Skip to content
Snippets Groups Projects
Commit 01cca5f4 authored by Andreas Valder's avatar Andreas Valder
Browse files

added tests

parent 07f925df
No related branches found
No related tags found
No related merge requests found
......@@ -16,22 +16,91 @@ class VideoTestCase(unittest.TestCase):
server.app.testing = True
self.app = server.app.test_client()
def login(self, c):
with c.session_transaction() as sess:
sess['user'] = {'name': 'videoag', '_csrf_token': 'asd', 'dbid': 72}
sess['_csrf_token'] = 'asd'
def test_index(self):
r = self.app.get('/')
with self.app as c:
r = c.get('/')
assert r.status_code == 200
self.login(c)
r = c.get('/')
assert r.status_code == 200
def test_courses(self):
r = self.app.get('/courses')
with self.app as c:
r = c.get('/courses')
assert r.status_code == 200
self.login(c)
r = c.get('/courses')
assert r.status_code == 200
def test_timetable(self):
with self.app as c:
r = c.get('/internal/timetable')
assert r.status_code == 302
self.login(c)
r = c.get('internal/timetable')
assert r.status_code == 200
r = c.get('internal/timetable?date=2016-W05')
assert r.status_code == 200
assert 'AfI' in r.data.decode()
assert 'Progra' in r.data.decode()
assert 'Bio' in r.data.decode()
def test_faq(self):
r = self.app.get('/faq')
assert r.status_code == 200
def test_ical(self):
with self.app as c:
r = c.get('/internal/ical/all')
assert r.status_code == 401
self.login(c)
r = c.get('/internal/ical/all')
assert r.status_code == 200
assert 'Progra' in r.data.decode()
assert 'Vorlesung' in r.data.decode()
def test_sitemap(self):
r = self.app.get('/sitemap.xml')
assert r.status_code == 200
def test_chapters(self):
with self.app as c:
# wrong time format
r = c.post('/internal/newchapter/7011', data={'text':'testchapter A', 'time': 1234})
assert r.status_code == 400
# should be inserted as id 15
r = c.post('/internal/newchapter/7011', data={'text':'testchapter B', 'time': '00:10:00'})
assert r.status_code == 200
# not yet set visible
r = c.get('/internal/chapters/7011')
assert r.status_code == 404
# other lecture
r = c.get('/internal/chapters/7012')
assert r.status_code == 404
self.login(c)
r = c.post('/internal/edit', data={"chapters.15.visible":1,"_csrf_token":"asd"})
assert r.status_code == 200
r = c.get('/internal/chapters/7011')
assert 'testchapter B' in r.data.decode() and not 'testchapter A' in r.data.decode()
def test_search(self):
r = self.app.get('/search?q=Malo')
assert r.status_code == 200
assert 'Mathematische Logik II' in r.data.decode() and '4.1 Der Sequenzenkalkül' in r.data.decode()
r = self.app.get('/search?q=Afi+Stens')
assert r.status_code == 200
assert 'Analysis für Informatiker' in r.data.decode() and 'Höhere Mathematik I' in r.data.decode()
def test_login(self):
# test login page
r = self.app.get('/internal/login')
......@@ -64,10 +133,11 @@ class VideoTestCase(unittest.TestCase):
r = c.get('/internal/new/courses', data={'title': 'Neue Vera14352345nstaltung totalyrandomcrap', 'responsible': 'foo', 'handle': '2r5sQ46z4w3DFCRT3<F4>DG', '_csrf_token': 'asd'})
assert r.status_code != 200
r = c.get('/internal/changelog')
assert r.status_code == 302
# all other tests are done logged in
with c.session_transaction() as sess:
sess['user'] = {'name': 'videoag', '_csrf_token': 'asd', 'dbid': 72}
sess['_csrf_token'] = 'asd'
self.login(c)
# add course
r = c.get('/internal/new/courses', data={'title': 'Neue Veranstaltung totalyrandomcrap', 'responsible': 'foo', 'handle': '2r5sQDFCRT3DG', '_csrf_token': 'asd'})
......@@ -76,6 +146,16 @@ class VideoTestCase(unittest.TestCase):
assert r.status_code == 200
assert 'Neue Veranstaltung totalyrandomcrap' in r.data.decode() and '2r5sQDFCRT3DG' in r.data.decode()
# rename lecture
r = c.get('internal/edit', data={"lectures.7353.title":"Testtitle","_csrf_token":"asd"})
assert r.status_code == 200
# test if the changelog is written
r = c.get('/internal/changelog')
assert r.status_code == 200
assert 'Testtitle' in r.data.decode() and 'lectures.7353.title' in r.data.decode()
def test_legacyurl(self):
with self.app as c:
r = self.app.get('/site/feed.php?newcourses')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment