-"""How to test wradmin:
-
-WRADMIN_SETTINGS=../wradmin/test.cfg python3 -m unittest tests.test_wradmin
-"""
import unittest
import bs4 # beautiful soup
+import wradmin.model
import wradmin
con.execute("UPDATE wrreport SET date_invalid = date_invalid + INTERVAL %s SECOND", (seconds_diff,))
con.execute("UPDATE wrreport SET delete_date = delete_date + INTERVAL %s SECOND", (seconds_diff,))
+ def test_bericht_list_auth(self):
+ result = self.app.get('/bericht/list')
+ self.assertEqual(result.status_code, 302)
+
def test_bericht_list(self):
+ result = self.app.post('/login', data={'user': 'john', 'password': 'doe'})
+ self.assertEqual(result.status_code, 200)
+
result = self.app.get('/bericht/list')
self.assertEqual(result.status_code, 200)
self.assertTrue(result.data.startswith(b'<!doctype html'))
self.assertIn('Gasthaus', soup.title.text)
self.assertIn('Meißner', str(soup))
- def test_gasthaus_update(self):
+ def test_gasthaus_update_success(self):
result = self.app.get('/gasthaus/update', follow_redirects=True)
self.assertEqual(result.status_code, 200)
self.assertTrue(result.data.startswith(b'<!doctype html'))
soup = bs4.BeautifulSoup(result.data, 'html.parser')
self.assertIn('Die Gasthausliste wurde erfolgreich aktualisiert.', str(soup))
+ def test_gasthaus_update_fail(self):
+ session = wradmin.model.meta.Session
+ text = session.query(wradmin.model.MwText).get(8719)
+ text.old_text = text.old_text.replace('maria-waldrast@aon.at', 'abc@def@example.com')
+ session.commit()
+ result = self.app.get('/gasthaus/update', follow_redirects=True)
+ self.assertEqual(result.status_code, 200)
+ self.assertTrue(result.data.startswith(b'<!doctype html'))
+ soup = bs4.BeautifulSoup(result.data, 'html.parser')
+ self.assertIn('Fehler bei Gasthaus \'Maria Waldrast (Klostergasthaus)\'', str(soup))
+
def test_rodelbahn_list(self):
result = self.app.get('/rodelbahn/list')
self.assertEqual(result.status_code, 200)
self.assertIn('Rodelbahn', soup.title.text)
self.assertIn('Hühnerspiel', str(soup))
- def test_rodelbahn_update(self):
+ def test_rodelbahn_update_success(self):
result = self.app.get('/rodelbahn/update', follow_redirects=True)
self.assertEqual(result.status_code, 200)
self.assertTrue(result.data.startswith(b'<!doctype html'))
soup = bs4.BeautifulSoup(result.data, 'html.parser')
self.assertIn('Die Rodelbahnliste wurde erfolgreich aktualisiert.', str(soup))
+ def test_rodelbahn_update_fail(self):
+ session = wradmin.model.meta.Session
+ text = session.query(wradmin.model.MwText).get(12106)
+ text.old_text = text.old_text.replace('Schwierigkeit = mittel', 'Schwierigkeit = geht so')
+ session.commit()
+ result = self.app.get('/rodelbahn/update', follow_redirects=True)
+ self.assertEqual(result.status_code, 200)
+ self.assertTrue(result.data.startswith(b'<!doctype html'))
+ soup = bs4.BeautifulSoup(result.data, 'html.parser')
+ self.assertIn('Fehler bei Rodelbahn \'Juifenalm\'', str(soup))
+
def test_rodelbahn_update_regioncache(self):
result = self.app.get('/rodelbahn/update_regioncache', follow_redirects=True)
self.assertEqual(result.status_code, 200)