Coverage for tests/test_app/management/commands/multi.py: 100%

17 statements  

« prev     ^ index     » next       coverage.py v7.3.4, created at 2024-01-20 17:58 +0000

1import json 

2from typing import List 

3 

4from django_typer import TyperCommand, command 

5 

6 

7class Command(TyperCommand): 

8 help = "Test multiple sub-commands." 

9 

10 @command() 

11 def cmd1(self, files: List[str], flag1: bool = False): 

12 """ 

13 A command that takes a list of files and a flag. 

14 """ 

15 assert self.__class__ == Command 

16 return json.dumps({"files": files, "flag1": flag1}) 

17 

18 @command() 

19 def sum(self, numbers: List[float]): 

20 """ 

21 Sum the given numbers. 

22 """ 

23 assert self.__class__ == Command 

24 return str(sum(numbers)) 

25 

26 @command() 

27 def cmd3(self): 

28 """ 

29 A command with no arguments. 

30 """ 

31 assert self.__class__ == Command 

32 return json.dumps({})