From 96c131940be45f19c3666351b71f6974e1f3563e Mon Sep 17 00:00:00 2001 From: imacat Date: Sat, 18 Mar 2023 03:08:08 +0800 Subject: [PATCH] Revised the date limitation tests in the OffsetTestCase test case, to be clear. --- tests/test_offset.py | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/tests/test_offset.py b/tests/test_offset.py index 194ed9b..e1ee6de 100644 --- a/tests/test_offset.py +++ b/tests/test_offset.py @@ -159,12 +159,13 @@ class OffsetTestCase(unittest.TestCase): self.assertEqual(response.headers["Location"], create_uri) # Not before the original entries - txn_data.days = self.data.e_r_or3d.txn.days + 1 + old_days = txn_data.days + txn_data.days = old_days + 1 form = txn_data.new_form(self.csrf_token) response = self.client.post(store_uri, data=form) self.assertEqual(response.status_code, 302) self.assertEqual(response.headers["Location"], create_uri) - txn_data.days = 0 + txn_data.days = old_days # Success form = txn_data.new_form(self.csrf_token) @@ -188,6 +189,8 @@ class OffsetTestCase(unittest.TestCase): form: dict[str, str] response: httpx.Response + txn_data.days = self.data.t_r_or2.days + # Non-existing original entry ID form = txn_data.update_form(self.csrf_token) form["currency-1-credit-1-original_entry_id"] = "9999" @@ -258,12 +261,13 @@ class OffsetTestCase(unittest.TestCase): self.assertEqual(response.headers["Location"], edit_uri) # Not before the original entries - txn_data.days = self.data.e_r_or3d.txn.days + 1 + old_days: int = txn_data.days + txn_data.days = old_days + 1 form = txn_data.update_form(self.csrf_token) response = self.client.post(update_uri, data=form) self.assertEqual(response.status_code, 302) self.assertEqual(response.headers["Location"], edit_uri) - txn_data.days = 0 + txn_data.days = old_days # Success form = txn_data.update_form(self.csrf_token) @@ -326,7 +330,7 @@ class OffsetTestCase(unittest.TestCase): # Not after the offset entries old_days: int = txn_data.days - txn_data.days = self.data.t_r_of1.days - 1 + txn_data.days = old_days - 1 form = txn_data.update_form(self.csrf_token) response = self.client.post(update_uri, data=form) self.assertEqual(response.status_code, 302) @@ -451,12 +455,13 @@ class OffsetTestCase(unittest.TestCase): self.assertEqual(response.headers["Location"], create_uri) # Not before the original entries - txn_data.days = self.data.e_p_or3c.txn.days + 1 + old_days: int = txn_data.days + txn_data.days = old_days + 1 form = txn_data.new_form(self.csrf_token) response = self.client.post(store_uri, data=form) self.assertEqual(response.status_code, 302) self.assertEqual(response.headers["Location"], create_uri) - txn_data.days = 0 + txn_data.days = old_days # Success form = txn_data.new_form(self.csrf_token) @@ -480,6 +485,8 @@ class OffsetTestCase(unittest.TestCase): form: dict[str, str] response: httpx.Response + txn_data.days = self.data.t_p_or2.days + # Non-existing original entry ID form = txn_data.update_form(self.csrf_token) form["currency-1-debit-1-original_entry_id"] = "9999" @@ -551,7 +558,7 @@ class OffsetTestCase(unittest.TestCase): # Not before the original entries old_days: int = txn_data.days - txn_data.days = self.data.e_p_or3c.txn.days + 1 + txn_data.days = old_days + 1 form = txn_data.update_form(self.csrf_token) response = self.client.post(update_uri, data=form) self.assertEqual(response.status_code, 302) @@ -622,7 +629,7 @@ class OffsetTestCase(unittest.TestCase): # Not after the offset entries old_days: int = txn_data.days - txn_data.days = self.data.t_p_of1.days - 1 + txn_data.days = old_days - 1 form = txn_data.update_form(self.csrf_token) response = self.client.post(update_uri, data=form) self.assertEqual(response.status_code, 302)