Refactor code for improved readability and consistency
CI / lint-test-build (push) Successful in 54s
CI / lint-test-build (push) Successful in 54s
- Cleaned up multiline statements and removed unnecessary line breaks in various files. - Ensured consistent formatting in function definitions and calls across the codebase. - Updated docstrings and comments for clarity where applicable. - Removed trailing newlines in module docstrings. - Enhanced logging statements for better clarity in maintenance tasks.
This commit is contained in:
@@ -49,9 +49,7 @@ def _mock_pg_store():
|
||||
@pytest.fixture
|
||||
def app():
|
||||
"""Create a test app with a mocked PgStore and audit repository."""
|
||||
a = create_app(
|
||||
Settings(_env_file=None, APP_MODE="paper", paper_trading_mode=True)
|
||||
)
|
||||
a = create_app(Settings(_env_file=None, APP_MODE="paper", paper_trading_mode=True))
|
||||
a.state.store = _mock_pg_store()
|
||||
a.state.runtime_state_repository.insert = AsyncMock()
|
||||
a.state.runtime_state_repository.latest = AsyncMock(return_value=None)
|
||||
@@ -69,16 +67,14 @@ async def test_persist_runtime_snapshot_writes_record(app) -> None:
|
||||
|
||||
# Mock _open_trade_count → 0, _latest_balances → None
|
||||
conn = await app.state.store.pool.acquire().__aenter__()
|
||||
conn.fetchrow = AsyncMock(return_value=MagicMock(
|
||||
**{"__getitem__": lambda s, k: 0}))
|
||||
conn.fetchrow = AsyncMock(return_value=MagicMock(**{"__getitem__": lambda s, k: 0}))
|
||||
|
||||
snapshot = await persist_runtime_snapshot(app, note="unit-test")
|
||||
|
||||
assert snapshot is not None
|
||||
assert snapshot.note == "unit-test"
|
||||
|
||||
app.state.runtime_state_repository.latest = AsyncMock(
|
||||
return_value=snapshot)
|
||||
app.state.runtime_state_repository.latest = AsyncMock(return_value=snapshot)
|
||||
latest = await app.state.runtime_state_repository.latest()
|
||||
assert latest is not None
|
||||
assert latest.note == "unit-test"
|
||||
|
||||
Reference in New Issue
Block a user