from os.path import split as path_split
from jinja2 import Environment as JinjaEnv, FileSystemLoader as JinjaFSLoader
from plomtask.days import Day, todays_date
-from plomtask.exceptions import HandledException, BadFormatException
+from plomtask.exceptions import HandledException, BadFormatException, \
+ NotFoundException
from plomtask.db import DatabaseConnection, DatabaseFile
from plomtask.processes import Process
html = self.do_GET_process(conn, id__)
elif 'processes' == site:
html = self.do_GET_processes(conn)
+ elif '' == site:
+ self._redirect('/day')
+ return
else:
- raise HandledException('Test!')
+ raise NotFoundException(f'Unknown page: /{site}')
conn.commit()
conn.close()
self._send_html(html)
"""Tests against our HTTP server/handler (and database)."""
def test_do_GET(self) -> None:
- """Test /day and /calendar response codes."""
+ """Test /day and /calendar response codes, and / redirect."""
self.conn.request('GET', '/day')
self.assertEqual(self.conn.getresponse().status, 200)
self.conn.request('GET', '/day?date=3000-01-01')
self.assertEqual(self.conn.getresponse().status, 200)
self.conn.request('GET', '/calendar?start=foo')
self.assertEqual(self.conn.getresponse().status, 400)
+ self.conn.request('GET', '/')
+ response = self.conn.getresponse()
+ self.assertEqual(response.status, 302)
+ self.assertEqual(response.getheader('Location'), '/day')