Step 2: Add seeding logic for pricing config
- Add seed_pricing_config() function to seed.py - Seed initial values from shared/constants.json - Add seeding to seed_e2e.py for E2E tests - Add tests for seeding functionality
This commit is contained in:
parent
32ce27180d
commit
74b934135a
3 changed files with 178 additions and 0 deletions
|
|
@ -1,6 +1,8 @@
|
|||
"""Fast re-seeding function for e2e tests - only seeds essential data."""
|
||||
|
||||
import json
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
from sqlalchemy import select
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
|
@ -13,6 +15,7 @@ from models import (
|
|||
Role,
|
||||
User,
|
||||
)
|
||||
from repositories.pricing import PricingRepository
|
||||
|
||||
|
||||
async def seed_base_data(db: AsyncSession) -> None:
|
||||
|
|
@ -95,4 +98,30 @@ async def seed_base_data(db: AsyncSession) -> None:
|
|||
admin_user.signal = None
|
||||
admin_user.nostr_npub = None
|
||||
|
||||
# Seed pricing config
|
||||
constants_path = Path(__file__).parent.parent / "shared" / "constants.json"
|
||||
with constants_path.open() as f:
|
||||
constants = json.load(f)
|
||||
|
||||
exchange_config = constants["exchange"]
|
||||
premium_percentage = exchange_config["premiumPercentage"]
|
||||
eur_trade_min = exchange_config["eurTradeMin"]
|
||||
eur_trade_max = exchange_config["eurTradeMax"]
|
||||
|
||||
# Convert EUR amounts to cents
|
||||
eur_min_cents = eur_trade_min * 100
|
||||
eur_max_cents = eur_trade_max * 100
|
||||
|
||||
repo = PricingRepository(db)
|
||||
await repo.create_or_update(
|
||||
premium_buy=premium_percentage,
|
||||
premium_sell=premium_percentage,
|
||||
small_trade_threshold_eur=0,
|
||||
small_trade_extra_premium=0,
|
||||
eur_min_buy=eur_min_cents,
|
||||
eur_max_buy=eur_max_cents,
|
||||
eur_min_sell=eur_min_cents,
|
||||
eur_max_sell=eur_max_cents,
|
||||
)
|
||||
|
||||
await db.commit()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue