Refactor code for improved readability and consistency
CI / lint-test-build (push) Failing after 12s
CI / lint-test-build (push) Failing after 12s
- Consolidated multiline string formatting into single-line for SQL queries in multiple files. - Adjusted argument formatting in function calls for better alignment and readability. - Removed unnecessary line breaks and improved spacing in various sections of the codebase. - Updated test cases to maintain consistency in formatting and improve clarity.
This commit is contained in:
@@ -6,10 +6,13 @@ from unittest.mock import Mock, patch
|
||||
from arbitrade.storage.repositories import (
|
||||
ConfigSettingRepository,
|
||||
ConfigPairingRepository,
|
||||
ConfigPairFeeRepository,
|
||||
ConfigBacktestingDefaultsRepository
|
||||
ConfigBacktestingDefaultsRepository,
|
||||
)
|
||||
from arbitrade.config.service import (
|
||||
ConfigSetting,
|
||||
ConfigPairing,
|
||||
ConfigBacktestingDefaults,
|
||||
)
|
||||
from arbitrade.config.service import ConfigSetting, ConfigPairing, ConfigPairFee, ConfigBacktestingDefaults
|
||||
from arbitrade.storage.db import DuckDBStore
|
||||
|
||||
|
||||
@@ -31,13 +34,20 @@ def test_config_setting_repository_create_setting(mock_store):
|
||||
repo = ConfigSettingRepository(mock_store)
|
||||
|
||||
# Mock database connection
|
||||
with patch.object(mock_store, 'connect') as mock_connect:
|
||||
with patch.object(mock_store, "connect") as mock_connect:
|
||||
mock_cursor = Mock()
|
||||
mock_connect.return_value.__enter__.return_value = mock_cursor
|
||||
|
||||
# Mock the return value
|
||||
mock_cursor.fetchone.return_value = [
|
||||
"test_key", "test_section", "test_value", "str", False, False, "2023-01-01T00:00:00", "test_user"
|
||||
"test_key",
|
||||
"test_section",
|
||||
"test_value",
|
||||
"str",
|
||||
False,
|
||||
False,
|
||||
"2023-01-01T00:00:00",
|
||||
"test_user",
|
||||
]
|
||||
|
||||
# Create setting
|
||||
@@ -48,7 +58,7 @@ def test_config_setting_repository_create_setting(mock_store):
|
||||
value_type="str",
|
||||
is_secret=False,
|
||||
is_runtime_reloadable=False,
|
||||
updated_by="test_user"
|
||||
updated_by="test_user",
|
||||
)
|
||||
|
||||
result = repo.create_setting(setting)
|
||||
@@ -67,13 +77,20 @@ def test_config_setting_repository_get_setting(mock_store):
|
||||
repo = ConfigSettingRepository(mock_store)
|
||||
|
||||
# Mock database connection
|
||||
with patch.object(mock_store, 'connect') as mock_connect:
|
||||
with patch.object(mock_store, "connect") as mock_connect:
|
||||
mock_cursor = Mock()
|
||||
mock_connect.return_value.__enter__.return_value = mock_cursor
|
||||
|
||||
# Mock the return value
|
||||
mock_cursor.fetchone.return_value = [
|
||||
"test_key", "test_section", "test_value", "str", False, False, "2023-01-01T00:00:00", "test_user"
|
||||
"test_key",
|
||||
"test_section",
|
||||
"test_value",
|
||||
"str",
|
||||
False,
|
||||
False,
|
||||
"2023-01-01T00:00:00",
|
||||
"test_user",
|
||||
]
|
||||
|
||||
# Get setting
|
||||
@@ -93,13 +110,20 @@ def test_config_setting_repository_update_setting(mock_store):
|
||||
repo = ConfigSettingRepository(mock_store)
|
||||
|
||||
# Mock database connection
|
||||
with patch.object(mock_store, 'connect') as mock_connect:
|
||||
with patch.object(mock_store, "connect") as mock_connect:
|
||||
mock_cursor = Mock()
|
||||
mock_connect.return_value.__enter__.return_value = mock_cursor
|
||||
|
||||
# Mock the return value
|
||||
mock_cursor.fetchone.return_value = [
|
||||
"test_key", "test_section", "updated_value", "str", False, False, "2023-01-01T00:00:00", "test_user"
|
||||
"test_key",
|
||||
"test_section",
|
||||
"updated_value",
|
||||
"str",
|
||||
False,
|
||||
False,
|
||||
"2023-01-01T00:00:00",
|
||||
"test_user",
|
||||
]
|
||||
|
||||
# Update setting
|
||||
@@ -110,7 +134,7 @@ def test_config_setting_repository_update_setting(mock_store):
|
||||
value_type="str",
|
||||
is_secret=False,
|
||||
is_runtime_reloadable=False,
|
||||
updated_by="test_user"
|
||||
updated_by="test_user",
|
||||
)
|
||||
|
||||
result = repo.update_setting("test_key", setting)
|
||||
@@ -129,16 +153,32 @@ def test_config_setting_repository_list_settings(mock_store):
|
||||
repo = ConfigSettingRepository(mock_store)
|
||||
|
||||
# Mock database connection
|
||||
with patch.object(mock_store, 'connect') as mock_connect:
|
||||
with patch.object(mock_store, "connect") as mock_connect:
|
||||
mock_cursor = Mock()
|
||||
mock_connect.return_value.__enter__.return_value = mock_cursor
|
||||
|
||||
# Mock the return value
|
||||
mock_cursor.fetchall.return_value = [
|
||||
["test_key1", "test_section", "test_value1", "str",
|
||||
False, False, "2023-01-01T00:00:00", "test_user"],
|
||||
["test_key2", "test_section", "test_value2", "str",
|
||||
False, False, "2023-01-01T00:00:00", "test_user"]
|
||||
[
|
||||
"test_key1",
|
||||
"test_section",
|
||||
"test_value1",
|
||||
"str",
|
||||
False,
|
||||
False,
|
||||
"2023-01-01T00:00:00",
|
||||
"test_user",
|
||||
],
|
||||
[
|
||||
"test_key2",
|
||||
"test_section",
|
||||
"test_value2",
|
||||
"str",
|
||||
False,
|
||||
False,
|
||||
"2023-01-01T00:00:00",
|
||||
"test_user",
|
||||
],
|
||||
]
|
||||
|
||||
# List settings
|
||||
@@ -156,7 +196,7 @@ def test_config_setting_repository_get_latest_updated_at(mock_store):
|
||||
repo = ConfigSettingRepository(mock_store)
|
||||
|
||||
# Mock database connection
|
||||
with patch.object(mock_store, 'connect') as mock_connect:
|
||||
with patch.object(mock_store, "connect") as mock_connect:
|
||||
mock_cursor = Mock()
|
||||
mock_connect.return_value.__enter__.return_value = mock_cursor
|
||||
|
||||
@@ -182,22 +222,24 @@ def test_config_pairing_repository_create_pairing(mock_store):
|
||||
repo = ConfigPairingRepository(mock_store)
|
||||
|
||||
# Mock database connection
|
||||
with patch.object(mock_store, 'connect') as mock_connect:
|
||||
with patch.object(mock_store, "connect") as mock_connect:
|
||||
mock_cursor = Mock()
|
||||
mock_connect.return_value.__enter__.return_value = mock_cursor
|
||||
|
||||
# Mock the return value
|
||||
mock_cursor.fetchone.return_value = [
|
||||
1, "BTC", "USD", True, "Kraken", "2023-01-01T00:00:00", "2023-01-01T00:00:00"
|
||||
1,
|
||||
"BTC",
|
||||
"USD",
|
||||
True,
|
||||
"Kraken",
|
||||
"2023-01-01T00:00:00",
|
||||
"2023-01-01T00:00:00",
|
||||
]
|
||||
|
||||
# Create pairing
|
||||
pairing = ConfigPairing(
|
||||
base_asset="BTC",
|
||||
quote_asset="USD",
|
||||
enabled=True,
|
||||
source="Kraken"
|
||||
)
|
||||
base_asset="BTC", quote_asset="USD", enabled=True, source="Kraken")
|
||||
|
||||
result = repo.create_pairing(pairing)
|
||||
|
||||
@@ -214,13 +256,19 @@ def test_config_pairing_repository_get_pairing(mock_store):
|
||||
repo = ConfigPairingRepository(mock_store)
|
||||
|
||||
# Mock database connection
|
||||
with patch.object(mock_store, 'connect') as mock_connect:
|
||||
with patch.object(mock_store, "connect") as mock_connect:
|
||||
mock_cursor = Mock()
|
||||
mock_connect.return_value.__enter__.return_value = mock_cursor
|
||||
|
||||
# Mock the return value
|
||||
mock_cursor.fetchone.return_value = [
|
||||
1, "BTC", "USD", True, "Kraken", "2023-01-01T00:00:00", "2023-01-01T00:00:00"
|
||||
1,
|
||||
"BTC",
|
||||
"USD",
|
||||
True,
|
||||
"Kraken",
|
||||
"2023-01-01T00:00:00",
|
||||
"2023-01-01T00:00:00",
|
||||
]
|
||||
|
||||
# Get pairing
|
||||
@@ -234,12 +282,6 @@ def test_config_pairing_repository_get_pairing(mock_store):
|
||||
assert result.source == "Kraken"
|
||||
|
||||
|
||||
def test_config_pair_fee_repository_initialization(mock_store):
|
||||
"""Test ConfigPairFeeRepository initialization."""
|
||||
repo = ConfigPairFeeRepository(mock_store)
|
||||
assert repo._store == mock_store
|
||||
|
||||
|
||||
def test_config_backtesting_defaults_repository_initialization(mock_store):
|
||||
"""Test ConfigBacktestingDefaultsRepository initialization."""
|
||||
repo = ConfigBacktestingDefaultsRepository(mock_store)
|
||||
|
||||
Reference in New Issue
Block a user