Replaced the import for the db object from the accounting model with the test site in test_account.py and test_currency.py. They are the same object, and the db object from the test site is safe at the compile time.
This commit is contained in:
parent
f878ba5535
commit
5a6e4f5b5e
@ -26,7 +26,7 @@ from click.testing import Result
|
||||
from flask import Flask
|
||||
from flask.testing import FlaskCliRunner
|
||||
|
||||
from test_site import create_app
|
||||
from test_site import create_app, db
|
||||
from testlib import get_client, set_locale
|
||||
|
||||
|
||||
@ -75,7 +75,6 @@ class AccountCommandTestCase(unittest.TestCase):
|
||||
|
||||
runner: FlaskCliRunner = self.app.test_cli_runner()
|
||||
with self.app.app_context():
|
||||
from accounting import db
|
||||
from accounting.models import BaseAccount, Account, AccountL10n
|
||||
result: Result
|
||||
result = runner.invoke(args="init-db")
|
||||
@ -129,7 +128,6 @@ class AccountTestCase(unittest.TestCase):
|
||||
|
||||
runner: FlaskCliRunner = self.app.test_cli_runner()
|
||||
with self.app.app_context():
|
||||
from accounting import db
|
||||
from accounting.models import BaseAccount, Account, AccountL10n
|
||||
result: Result
|
||||
result = runner.invoke(args="init-db")
|
||||
@ -316,7 +314,6 @@ class AccountTestCase(unittest.TestCase):
|
||||
|
||||
:return: None.
|
||||
"""
|
||||
from accounting import db
|
||||
from accounting.models import Account
|
||||
create_uri: str = f"{PREFIX}/create"
|
||||
store_uri: str = f"{PREFIX}/store"
|
||||
@ -489,7 +486,6 @@ 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"
|
||||
@ -652,7 +648,6 @@ class AccountTestCase(unittest.TestCase):
|
||||
|
||||
:return: None.
|
||||
"""
|
||||
from accounting import db
|
||||
from accounting.models import Account
|
||||
response: httpx.Response
|
||||
|
||||
@ -704,7 +699,6 @@ class AccountTestCase(unittest.TestCase):
|
||||
|
||||
:return: None.
|
||||
"""
|
||||
from accounting import db
|
||||
from accounting.models import Account
|
||||
response: httpx.Response
|
||||
|
||||
|
@ -27,7 +27,7 @@ from click.testing import Result
|
||||
from flask import Flask
|
||||
from flask.testing import FlaskCliRunner
|
||||
|
||||
from test_site import create_app
|
||||
from test_site import create_app, db
|
||||
from testlib import get_client, set_locale
|
||||
|
||||
|
||||
@ -71,7 +71,6 @@ class CurrencyCommandTestCase(unittest.TestCase):
|
||||
|
||||
runner: FlaskCliRunner = self.app.test_cli_runner()
|
||||
with self.app.app_context():
|
||||
from accounting import db
|
||||
from accounting.models import Currency, CurrencyL10n
|
||||
result: Result
|
||||
result = runner.invoke(args="init-db")
|
||||
@ -128,7 +127,6 @@ class CurrencyTestCase(unittest.TestCase):
|
||||
|
||||
runner: FlaskCliRunner = self.app.test_cli_runner()
|
||||
with self.app.app_context():
|
||||
from accounting import db
|
||||
from accounting.models import Currency, CurrencyL10n
|
||||
result: Result
|
||||
result = runner.invoke(args="init-db")
|
||||
@ -270,7 +268,6 @@ class CurrencyTestCase(unittest.TestCase):
|
||||
:return: None.
|
||||
"""
|
||||
from accounting.models import Currency
|
||||
from test_site import db
|
||||
create_uri: str = f"{PREFIX}/create"
|
||||
store_uri: str = f"{PREFIX}/store"
|
||||
detail_uri: str = f"{PREFIX}/{zzc.code}"
|
||||
@ -355,7 +352,6 @@ class CurrencyTestCase(unittest.TestCase):
|
||||
:return: None.
|
||||
"""
|
||||
from accounting.models import Currency
|
||||
from test_site import db
|
||||
detail_uri: str = f"{PREFIX}/{zza.code}"
|
||||
edit_uri: str = f"{PREFIX}/{zza.code}/edit"
|
||||
update_uri: str = f"{PREFIX}/{zza.code}/update"
|
||||
@ -435,7 +431,6 @@ class CurrencyTestCase(unittest.TestCase):
|
||||
:return: None.
|
||||
"""
|
||||
from accounting.models import Currency
|
||||
from test_site import db
|
||||
detail_uri: str = f"{PREFIX}/{zza.code}"
|
||||
update_uri: str = f"{PREFIX}/{zza.code}/update"
|
||||
zza_currency: Currency
|
||||
@ -475,7 +470,6 @@ class CurrencyTestCase(unittest.TestCase):
|
||||
:return: None.
|
||||
"""
|
||||
from accounting.models import Currency
|
||||
from test_site import db
|
||||
editor_username, editor2_username = "editor", "editor2"
|
||||
client, csrf_token = get_client(self.app, editor2_username)
|
||||
detail_uri: str = f"{PREFIX}/{zza.code}"
|
||||
@ -526,7 +520,6 @@ class CurrencyTestCase(unittest.TestCase):
|
||||
:return: None
|
||||
"""
|
||||
from accounting.models import Currency
|
||||
from test_site import db
|
||||
detail_uri: str = f"{PREFIX}/{zza.code}"
|
||||
update_uri: str = f"{PREFIX}/{zza.code}/update"
|
||||
response: httpx.Response
|
||||
|
Loading…
Reference in New Issue
Block a user