diff --git a/tests/test_account.py b/tests/test_account.py index 789f6f2..8f4f095 100644 --- a/tests/test_account.py +++ b/tests/test_account.py @@ -17,8 +17,8 @@ """The test for the account management. """ -import time import unittest +from datetime import timedelta import httpx import sqlalchemy as sa @@ -489,12 +489,12 @@ class AccountTestCase(unittest.TestCase): :return: None. """ + from accounting import db from accounting.models import Account detail_uri: str = f"{PREFIX}/{cash.code}" update_uri: str = f"{PREFIX}/{cash.code}/update" cash_account: Account response: httpx.Response - time.sleep(1) response = self.client.post(update_uri, data={"csrf_token": self.csrf_token, @@ -506,7 +506,10 @@ class AccountTestCase(unittest.TestCase): with self.app.app_context(): cash_account = Account.find_by_code(cash.code) self.assertIsNotNone(cash_account) - self.assertEqual(cash_account.created_at, cash_account.updated_at) + cash_account.created_at \ + = cash_account.created_at - timedelta(seconds=5) + cash_account.updated_at = cash_account.created_at + db.session.commit() response = self.client.post(update_uri, data={"csrf_token": self.csrf_token, diff --git a/tests/test_currency.py b/tests/test_currency.py index 6708540..30009c1 100644 --- a/tests/test_currency.py +++ b/tests/test_currency.py @@ -18,9 +18,9 @@ """ import csv -import time import typing as t import unittest +from datetime import timedelta import httpx from click.testing import Result @@ -440,7 +440,6 @@ class CurrencyTestCase(unittest.TestCase): update_uri: str = f"{PREFIX}/{zza.code}/update" zza_currency: Currency response: httpx.Response - time.sleep(1) response = self.client.post(update_uri, data={"csrf_token": self.csrf_token, @@ -452,7 +451,10 @@ class CurrencyTestCase(unittest.TestCase): with self.app.app_context(): zza_currency = db.session.get(Currency, zza.code) self.assertIsNotNone(zza_currency) - self.assertEqual(zza_currency.created_at, zza_currency.updated_at) + zza_currency.created_at \ + = zza_currency.created_at - timedelta(seconds=5) + zza_currency.updated_at = zza_currency.created_at + db.session.commit() response = self.client.post(update_uri, data={"csrf_token": self.csrf_token,