Coverage for tests/django_tests/db/orders/test_order.py: 100%
18 statements
« prev ^ index » next coverage.py v7.4.3, created at 2024-03-12 13:49 +0000
« prev ^ index » next coverage.py v7.4.3, created at 2024-03-12 13:49 +0000
1from django_napse.core.models import Bot, Connection, Controller, EmptyBotConfig, EmptyStrategy, Order, OrderBatch, SinglePairArchitecture
2from django_napse.utils.constants import SIDES
3from django_napse.utils.model_test_case import ModelTestCase
5"""
6python tests/test_app/manage.py test tests.django_tests.orders.test_order -v2 --keepdb --parallel
7"""
10class OrderTestCase:
11 model = Order
13 def simple_create(self):
14 config = EmptyBotConfig.objects.create(space=self.space, settings={"empty": True})
15 controller = Controller.get(
16 exchange_account=self.exchange_account,
17 base="BTC",
18 quote="USDT",
19 interval="1m",
20 )
21 architecture = SinglePairArchitecture.objects.create(constants={"controller": controller})
22 strategy = EmptyStrategy.objects.create(config=config, architecture=architecture)
23 bot = Bot.objects.create(name="Test Bot", strategy=strategy)
24 connection = Connection.objects.create(owner=self.space.wallet, bot=bot)
25 connection.wallet.top_up(amount=10000, ticker="USDT", force=True)
26 batch = OrderBatch.objects.create(controller=controller)
27 return Order.objects.create(
28 batch=batch,
29 connection=connection,
30 asked_for_amount=10,
31 asked_for_ticker="USDT",
32 price=30000,
33 pair="BTCUSDT",
34 side=SIDES.BUY,
35 )
38class OrderBINANCETestCase(OrderTestCase, ModelTestCase):
39 exchange = "BINANCE"