+ def test_bericht_view(self):
+ result = self.app.get('/bericht/view/19591')
+ self.assertEqual(result.status_code, 200)
+ self.assertTrue(result.data.startswith(b'<!doctype html'))
+ soup = bs4.BeautifulSoup(result.data, 'html.parser')
+ self.assertEqual(soup.title.text, 'Rodelbahnbericht #19591')
+ self.assertIn('Brandstatt Alm', str(soup.table))
+
+ def test_bericht_change_date_invalid_twoweeks(self):
+ post_data = {'date_invalid': 'two_weeks', 'date_userdefined': '2018-01-30 18:26'}
+ result = self.app.post('/bericht/change_date_invalid/19591', data=post_data, 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.assertEqual(soup.title.text, 'Rodelbahnbericht #19591')
+ self.assertIn('Datum wurde erfolgreich geändert', str(soup))
+
+ def test_bericht_change_date_invalid_userdefined(self):
+ post_data = {'date_invalid': 'userdefined', 'date_userdefined': '2018-01-30 15:09'}
+ result = self.app.post('/bericht/change_date_invalid/19591', data=post_data, 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.assertEqual(soup.title.text, 'Rodelbahnbericht #19591')
+ self.assertIn('Datum wurde erfolgreich geändert', str(soup))
+ self.assertIn('2018-01-30 15:09:00', str(soup))
+
+ def test_gasthaus_list(self):
+ result = self.app.get('/gasthaus/list')
+ self.assertEqual(result.status_code, 200)
+ self.assertTrue(result.data.startswith(b'<!doctype html'))
+ soup = bs4.BeautifulSoup(result.data, 'html.parser')
+ self.assertEqual(soup.title.text, 'Gasthäuser')
+ self.assertIn('Meißner', str(soup.table))
+
+ def test_gasthaus_view(self):
+ result = self.app.get('/gasthaus/view/362')
+ self.assertEqual(result.status_code, 200)
+ self.assertTrue(result.data.startswith(b'<!doctype html'))
+ soup = bs4.BeautifulSoup(result.data, 'html.parser')
+ self.assertIn('Gasthaus', soup.title.text)
+ self.assertIn('Meißner', str(soup))
+
+ 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))
+