Coverage for tests/test_app/management/commands/test_command1.py: 0%

15 statements  

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

1import json 

2 

3from django_typer import TyperCommand, command, initialize 

4 

5 

6class Command(TyperCommand): 

7 help = "This is a test help message" 

8 

9 @initialize(epilog="This is a test callback epilog") 

10 def preamble(self, pre_arg: str = "pre_arg"): 

11 print(f"This is a test preamble, {pre_arg}") 

12 

13 @command(epilog="This is a test epilog") 

14 def delete(self, name: str, formal: bool = False, throw: bool = False): 

15 """Delete something""" 

16 if throw: 

17 raise Exception("This is a test exception") 

18 print(json.dumps({"name": name, "formal": formal})) 

19 

20 @command(epilog="This is a test epilog") 

21 def create(self, name: str, number: int, switch: bool = False): 

22 """This is a test create command""" 

23 print(json.dumps({"name": name, "number": number, "switch": switch}))