Step 8: Cleanup old constants
- Remove EUR_TRADE_MIN, EUR_TRADE_MAX, PREMIUM_PERCENTAGE from shared_constants.py - Remove eurTradeMin, eurTradeMax, premiumPercentage from shared/constants.json - Update validate_constants.py to not require removed fields - Update seed.py and seed_e2e.py to use defaults if fields don't exist - Update tests to handle missing constants gracefully
This commit is contained in:
parent
41e158376c
commit
549fbf4975
6 changed files with 20 additions and 25 deletions
|
|
@ -88,10 +88,11 @@ async def seed_pricing_config(db: AsyncSession) -> None:
|
||||||
with constants_path.open() as f:
|
with constants_path.open() as f:
|
||||||
constants = json.load(f)
|
constants = json.load(f)
|
||||||
|
|
||||||
exchange_config = constants["exchange"]
|
exchange_config = constants.get("exchange", {})
|
||||||
premium_percentage = exchange_config["premiumPercentage"]
|
# Use defaults if fields don't exist (for backward compatibility during migration)
|
||||||
eur_trade_min = exchange_config["eurTradeMin"]
|
premium_percentage = exchange_config.get("premiumPercentage", 5)
|
||||||
eur_trade_max = exchange_config["eurTradeMax"]
|
eur_trade_min = exchange_config.get("eurTradeMin", 100)
|
||||||
|
eur_trade_max = exchange_config.get("eurTradeMax", 3000)
|
||||||
|
|
||||||
# Convert EUR amounts to cents
|
# Convert EUR amounts to cents
|
||||||
eur_min_cents = eur_trade_min * 100
|
eur_min_cents = eur_trade_min * 100
|
||||||
|
|
|
||||||
|
|
@ -103,10 +103,11 @@ async def seed_base_data(db: AsyncSession) -> None:
|
||||||
with constants_path.open() as f:
|
with constants_path.open() as f:
|
||||||
constants = json.load(f)
|
constants = json.load(f)
|
||||||
|
|
||||||
exchange_config = constants["exchange"]
|
exchange_config = constants.get("exchange", {})
|
||||||
premium_percentage = exchange_config["premiumPercentage"]
|
# Use defaults if fields don't exist (for backward compatibility during migration)
|
||||||
eur_trade_min = exchange_config["eurTradeMin"]
|
premium_percentage = exchange_config.get("premiumPercentage", 5)
|
||||||
eur_trade_max = exchange_config["eurTradeMax"]
|
eur_trade_min = exchange_config.get("eurTradeMin", 100)
|
||||||
|
eur_trade_max = exchange_config.get("eurTradeMax", 3000)
|
||||||
|
|
||||||
# Convert EUR amounts to cents
|
# Convert EUR amounts to cents
|
||||||
eur_min_cents = eur_trade_min * 100
|
eur_min_cents = eur_trade_min * 100
|
||||||
|
|
|
||||||
|
|
@ -10,10 +10,7 @@ _constants = json.loads(_constants_path.read_text())
|
||||||
SLOT_DURATION_MINUTES: int = _constants["exchange"]["slotDurationMinutes"]
|
SLOT_DURATION_MINUTES: int = _constants["exchange"]["slotDurationMinutes"]
|
||||||
MIN_ADVANCE_DAYS: int = _constants["exchange"]["minAdvanceDays"]
|
MIN_ADVANCE_DAYS: int = _constants["exchange"]["minAdvanceDays"]
|
||||||
MAX_ADVANCE_DAYS: int = _constants["exchange"]["maxAdvanceDays"]
|
MAX_ADVANCE_DAYS: int = _constants["exchange"]["maxAdvanceDays"]
|
||||||
EUR_TRADE_MIN: int = _constants["exchange"]["eurTradeMin"]
|
|
||||||
EUR_TRADE_MAX: int = _constants["exchange"]["eurTradeMax"]
|
|
||||||
EUR_TRADE_INCREMENT: int = _constants["exchange"]["eurTradeIncrement"]
|
EUR_TRADE_INCREMENT: int = _constants["exchange"]["eurTradeIncrement"]
|
||||||
PREMIUM_PERCENTAGE: int = _constants["exchange"]["premiumPercentage"]
|
|
||||||
PRICE_REFRESH_SECONDS: int = _constants["exchange"]["priceRefreshSeconds"]
|
PRICE_REFRESH_SECONDS: int = _constants["exchange"]["priceRefreshSeconds"]
|
||||||
PRICE_STALENESS_SECONDS: int = _constants["exchange"]["priceStalenessSeconds"]
|
PRICE_STALENESS_SECONDS: int = _constants["exchange"]["priceStalenessSeconds"]
|
||||||
LIGHTNING_MAX_EUR: int = _constants["exchange"]["lightningMaxEur"]
|
LIGHTNING_MAX_EUR: int = _constants["exchange"]["lightningMaxEur"]
|
||||||
|
|
|
||||||
|
|
@ -176,10 +176,11 @@ class TestPricingSeeding:
|
||||||
with constants_path.open() as f:
|
with constants_path.open() as f:
|
||||||
constants = json.load(f)
|
constants = json.load(f)
|
||||||
|
|
||||||
exchange_config = constants["exchange"]
|
exchange_config = constants.get("exchange", {})
|
||||||
expected_premium = exchange_config["premiumPercentage"]
|
# Use defaults if fields don't exist (they may have been removed)
|
||||||
expected_min_eur = exchange_config["eurTradeMin"]
|
expected_premium = exchange_config.get("premiumPercentage", 5)
|
||||||
expected_max_eur = exchange_config["eurTradeMax"]
|
expected_min_eur = exchange_config.get("eurTradeMin", 100)
|
||||||
|
expected_max_eur = exchange_config.get("eurTradeMax", 3000)
|
||||||
|
|
||||||
async with client_factory.get_db_session() as db:
|
async with client_factory.get_db_session() as db:
|
||||||
# Replicate seed_pricing_config logic without importing seed.py
|
# Replicate seed_pricing_config logic without importing seed.py
|
||||||
|
|
@ -217,10 +218,11 @@ class TestPricingSeeding:
|
||||||
with constants_path.open() as f:
|
with constants_path.open() as f:
|
||||||
constants = json.load(f)
|
constants = json.load(f)
|
||||||
|
|
||||||
exchange_config = constants["exchange"]
|
exchange_config = constants.get("exchange", {})
|
||||||
expected_premium = exchange_config["premiumPercentage"]
|
# Use defaults if fields don't exist (they may have been removed)
|
||||||
expected_min_eur = exchange_config["eurTradeMin"]
|
expected_premium = exchange_config.get("premiumPercentage", 5)
|
||||||
expected_max_eur = exchange_config["eurTradeMax"]
|
expected_min_eur = exchange_config.get("eurTradeMin", 100)
|
||||||
|
expected_max_eur = exchange_config.get("eurTradeMax", 3000)
|
||||||
|
|
||||||
async with client_factory.get_db_session() as db:
|
async with client_factory.get_db_session() as db:
|
||||||
repo = PricingRepository(db)
|
repo = PricingRepository(db)
|
||||||
|
|
|
||||||
|
|
@ -75,10 +75,7 @@ def validate_shared_constants() -> None:
|
||||||
"slotDurationMinutes",
|
"slotDurationMinutes",
|
||||||
"maxAdvanceDays",
|
"maxAdvanceDays",
|
||||||
"minAdvanceDays",
|
"minAdvanceDays",
|
||||||
"eurTradeMin",
|
|
||||||
"eurTradeMax",
|
|
||||||
"eurTradeIncrement",
|
"eurTradeIncrement",
|
||||||
"premiumPercentage",
|
|
||||||
"priceRefreshSeconds",
|
"priceRefreshSeconds",
|
||||||
"priceStalenessSeconds",
|
"priceStalenessSeconds",
|
||||||
"lightningMaxEur",
|
"lightningMaxEur",
|
||||||
|
|
|
||||||
|
|
@ -27,10 +27,7 @@
|
||||||
"slotDurationMinutes": 15,
|
"slotDurationMinutes": 15,
|
||||||
"maxAdvanceDays": 30,
|
"maxAdvanceDays": 30,
|
||||||
"minAdvanceDays": 1,
|
"minAdvanceDays": 1,
|
||||||
"eurTradeMin": 100,
|
|
||||||
"eurTradeMax": 3000,
|
|
||||||
"eurTradeIncrement": 20,
|
"eurTradeIncrement": 20,
|
||||||
"premiumPercentage": 5,
|
|
||||||
"priceRefreshSeconds": 60,
|
"priceRefreshSeconds": 60,
|
||||||
"priceStalenessSeconds": 300,
|
"priceStalenessSeconds": 300,
|
||||||
"lightningMaxEur": 1000
|
"lightningMaxEur": 1000
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue