Coverage for tests/django_tests/db/bots/test_bot_config.py: 100%
30 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 typing import ClassVar
3from django_napse.core.models import EmptyBotConfig, NapseSpace
4from django_napse.utils.errors import BotConfigError
5from django_napse.utils.model_test_case import ModelTestCase
7"""
8python tests/test_app/manage.py test tests.django_tests.bots.test_bot_config -v2 --keepdb --parallel
9"""
12class BotConfigDefaultTestCase:
13 def simple_create(self):
14 return self.model.objects.create(space=self.space, settings=self.settings)
16 def test_error_duplicate(self):
17 self.simple_create()
18 with self.assertRaises(BotConfigError.DuplicateBotConfig):
19 self.simple_create()
21 def test_missing_setting(self):
22 with self.assertRaises(BotConfigError.MissingSettingError):
23 self.model.objects.create(space=self.space, settings={})
25 def test_duplicate_immutable(self):
26 config = self.simple_create()
27 config.duplicate_immutable()
28 config.duplicate_immutable()
30 def test_duplicate_other_space(self):
31 config = self.simple_create()
32 with self.assertRaises(ValueError):
33 config.duplicate_other_space(self.space)
34 new_space = NapseSpace.objects.create(name="Test Space 2", exchange_account=self.exchange_account, description="This is a test space")
35 config.duplicate_other_space(new_space)
38class EmptyBotConfigTestCase(BotConfigDefaultTestCase):
39 model = EmptyBotConfig
40 settings: ClassVar = {"empty": True}
43class EmptyBotConfigBINANCETestCase(EmptyBotConfigTestCase, ModelTestCase):
44 exchange = "BINANCE"