home
·
contact
·
privacy
projects
/
plomtask
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Enable deletion of Conditions.
[plomtask]
/
tests
/
utils.py
diff --git
a/tests/utils.py
b/tests/utils.py
index c80b34da9f3405ddabf563e577e8406af4e155eb..34f429e9d1fcc6355cdb9d7eae8f60c9e125b2d5 100644
(file)
--- a/
tests/utils.py
+++ b/
tests/utils.py
@@
-8,12
+8,21
@@
from os import remove as remove_file
from typing import Mapping
from plomtask.db import DatabaseFile, DatabaseConnection
from plomtask.http import TaskHandler, TaskServer
from typing import Mapping
from plomtask.db import DatabaseFile, DatabaseConnection
from plomtask.http import TaskHandler, TaskServer
+from plomtask.processes import Process, ProcessStep
+from plomtask.conditions import Condition
+from plomtask.days import Day
+from plomtask.todos import Todo
class TestCaseWithDB(TestCase):
"""Module tests not requiring DB setup."""
def setUp(self) -> None:
class TestCaseWithDB(TestCase):
"""Module tests not requiring DB setup."""
def setUp(self) -> None:
+ Condition.empty_cache()
+ Day.empty_cache()
+ Process.empty_cache()
+ ProcessStep.empty_cache()
+ Todo.empty_cache()
timestamp = datetime.now().timestamp()
self.db_file = DatabaseFile(f'test_db:{timestamp}')
self.db_file.remake()
timestamp = datetime.now().timestamp()
self.db_file = DatabaseFile(f'test_db:{timestamp}')
self.db_file.remake()
@@
-54,7
+63,7
@@
class TestCaseWithServer(TestCaseWithDB):
self.assertEqual(self.conn.getresponse().status, expected_code)
def check_post(self, data: Mapping[str, object], target: str,
self.assertEqual(self.conn.getresponse().status, expected_code)
def check_post(self, data: Mapping[str, object], target: str,
- expected_code: int, redirect_location: str = '
/
') -> None:
+ expected_code: int, redirect_location: str = '') -> None:
"""Check that POST of data to target yields expected_code."""
encoded_form_data = urlencode(data, doseq=True).encode('utf-8')
headers = {'Content-Type': 'application/x-www-form-urlencoded',
"""Check that POST of data to target yields expected_code."""
encoded_form_data = urlencode(data, doseq=True).encode('utf-8')
headers = {'Content-Type': 'application/x-www-form-urlencoded',
@@
-62,6
+71,8
@@
class TestCaseWithServer(TestCaseWithDB):
self.conn.request('POST', target,
body=encoded_form_data, headers=headers)
if 302 == expected_code:
self.conn.request('POST', target,
body=encoded_form_data, headers=headers)
if 302 == expected_code:
+ if redirect_location == '':
+ redirect_location = target
self.check_redirect(redirect_location)
else:
self.assertEqual(self.conn.getresponse().status, expected_code)
self.check_redirect(redirect_location)
else:
self.assertEqual(self.conn.getresponse().status, expected_code)