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 login(self):
+ return self.app.post('/login', data={'user': 'john', 'password': 'doe'})
- def test_bericht_list(self):
- result = self.app.post('/login', data={'user': 'john', 'password': 'doe'})
+ def login_and_get(self, url: str):
+ result = self.app.get(url)
+ self.assertEqual(result.status_code, 302)
+ result = self.login()
self.assertEqual(result.status_code, 200)
-
- result = self.app.get('/bericht/list')
+ result = self.app.get(url)
self.assertEqual(result.status_code, 200)
+ return result
+
+ def test_bericht_list(self):
+ result = self.login_and_get('/bericht/list')
self.assertTrue(result.data.startswith(b'<!doctype html'))
soup = bs4.BeautifulSoup(result.data, 'html.parser')
self.assertEqual(soup.title.text, 'Rodelbahnberichte')
def test_bericht_view(self):
- result = self.app.get('/bericht/view/19591')
- self.assertEqual(result.status_code, 200)
+ result = self.login_and_get('/bericht/view/19591')
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):
+ url = '/bericht/change_date_invalid/19591'
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)
+ result = self.app.post(url, data=post_data, follow_redirects=True)
+ self.assertEqual(result.status_code, 302)
+ self.login()
+ self.assertEqual(result.status_code, 200)
+ result = self.app.post(url, 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')