X-Git-Url: https://plomlompom.com/repos/feed.xml?a=blobdiff_plain;f=tests%2Futils.py;h=63b07e93e6f14ca51426e2fc00e959fdbfca7bf1;hb=8570f4ce4d44b813a1f02b72c5c45a57d2003bae;hp=d41e7b39ad5fe07abdc701be674d9f81678cd30f;hpb=4724d02b2c8a7fac3029ae6380641c4093fa4554;p=plomtask diff --git a/tests/utils.py b/tests/utils.py index d41e7b3..63b07e9 100644 --- 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 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: + 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() @@ -54,9 +63,9 @@ class TestCaseWithServer(TestCaseWithDB): 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).encode('utf-8') + encoded_form_data = urlencode(data, doseq=True).encode('utf-8') headers = {'Content-Type': 'application/x-www-form-urlencoded', 'Content-Length': str(len(encoded_form_data))} self.conn.request('POST', target,