Coverage for tests/django_tests/db/bots/test_bot.py: 100%

24 statements  

« prev     ^ index     » next       coverage.py v7.4.3, created at 2024-03-12 13:49 +0000

1from typing import ClassVar 

2 

3from django_napse.core.models import Bot, Controller, EmptyStrategy 

4from django_napse.utils.model_test_case import ModelTestCase 

5 

6""" 

7python tests/test_app/manage.py test tests.django_tests.bots.test_bot -v2 --keepdb --parallel 

8""" 

9 

10 

11class BotDefaultTestCase: 

12 model = Bot 

13 strategy_class = EmptyStrategy 

14 config_settings: ClassVar = {"empty": True} 

15 

16 @property 

17 def architecture_constants(self): 

18 return { 

19 "controller": Controller.get( 

20 exchange_account=self.exchange_account, 

21 base="BTC", 

22 quote="USDT", 

23 interval="1d", 

24 ), 

25 } 

26 

27 def simple_create(self): 

28 return self.model.objects.create(name="Test Bot", strategy=self.strategy) 

29 

30 @property 

31 def config(self): 

32 return self.strategy_class.config_class().objects.create(space=self.space, settings=self.config_settings) 

33 

34 @property 

35 def architecture(self): 

36 return self.strategy_class.architecture_class().objects.create(constants=self.architecture_constants) 

37 

38 @property 

39 def strategy(self): 

40 return self.strategy_class.objects.create(config=self.config, architecture=self.architecture) 

41 

42 

43class BotBINANCETestCase(BotDefaultTestCase, ModelTestCase): 

44 exchange = "BINANCE"