Revised to rewind the time in the test_update_not_modified tests of the AccountTestCase and CurrencyTestCase test cases, so that the test cases don't have to wait for the time to be different.
This commit is contained in:
parent
e7c36ba13a
commit
f878ba5535
@ -17,8 +17,8 @@
|
|||||||
"""The test for the account management.
|
"""The test for the account management.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
import time
|
|
||||||
import unittest
|
import unittest
|
||||||
|
from datetime import timedelta
|
||||||
|
|
||||||
import httpx
|
import httpx
|
||||||
import sqlalchemy as sa
|
import sqlalchemy as sa
|
||||||
@ -489,12 +489,12 @@ class AccountTestCase(unittest.TestCase):
|
|||||||
|
|
||||||
:return: None.
|
:return: None.
|
||||||
"""
|
"""
|
||||||
|
from accounting import db
|
||||||
from accounting.models import Account
|
from accounting.models import Account
|
||||||
detail_uri: str = f"{PREFIX}/{cash.code}"
|
detail_uri: str = f"{PREFIX}/{cash.code}"
|
||||||
update_uri: str = f"{PREFIX}/{cash.code}/update"
|
update_uri: str = f"{PREFIX}/{cash.code}/update"
|
||||||
cash_account: Account
|
cash_account: Account
|
||||||
response: httpx.Response
|
response: httpx.Response
|
||||||
time.sleep(1)
|
|
||||||
|
|
||||||
response = self.client.post(update_uri,
|
response = self.client.post(update_uri,
|
||||||
data={"csrf_token": self.csrf_token,
|
data={"csrf_token": self.csrf_token,
|
||||||
@ -506,7 +506,10 @@ class AccountTestCase(unittest.TestCase):
|
|||||||
with self.app.app_context():
|
with self.app.app_context():
|
||||||
cash_account = Account.find_by_code(cash.code)
|
cash_account = Account.find_by_code(cash.code)
|
||||||
self.assertIsNotNone(cash_account)
|
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,
|
response = self.client.post(update_uri,
|
||||||
data={"csrf_token": self.csrf_token,
|
data={"csrf_token": self.csrf_token,
|
||||||
|
@ -18,9 +18,9 @@
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
import csv
|
import csv
|
||||||
import time
|
|
||||||
import typing as t
|
import typing as t
|
||||||
import unittest
|
import unittest
|
||||||
|
from datetime import timedelta
|
||||||
|
|
||||||
import httpx
|
import httpx
|
||||||
from click.testing import Result
|
from click.testing import Result
|
||||||
@ -440,7 +440,6 @@ class CurrencyTestCase(unittest.TestCase):
|
|||||||
update_uri: str = f"{PREFIX}/{zza.code}/update"
|
update_uri: str = f"{PREFIX}/{zza.code}/update"
|
||||||
zza_currency: Currency
|
zza_currency: Currency
|
||||||
response: httpx.Response
|
response: httpx.Response
|
||||||
time.sleep(1)
|
|
||||||
|
|
||||||
response = self.client.post(update_uri,
|
response = self.client.post(update_uri,
|
||||||
data={"csrf_token": self.csrf_token,
|
data={"csrf_token": self.csrf_token,
|
||||||
@ -452,7 +451,10 @@ class CurrencyTestCase(unittest.TestCase):
|
|||||||
with self.app.app_context():
|
with self.app.app_context():
|
||||||
zza_currency = db.session.get(Currency, zza.code)
|
zza_currency = db.session.get(Currency, zza.code)
|
||||||
self.assertIsNotNone(zza_currency)
|
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,
|
response = self.client.post(update_uri,
|
||||||
data={"csrf_token": self.csrf_token,
|
data={"csrf_token": self.csrf_token,
|
||||||
|
Loading…
Reference in New Issue
Block a user