-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_config.py
83 lines (76 loc) · 2.56 KB
/
test_config.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
from django_typer.management import get_command
from django.test import TestCase, override_settings
from django.core.exceptions import ImproperlyConfigured
from django.core.management import CommandError, call_command
from django_routines import get_routine
class TestBadConfig(TestCase):
@override_settings(
DJANGO_ROUTINES={
"no_name": {
"commands": [
{"command": ("track", "0")},
{"command": ("does_not_exist",)},
{"command": ("track", "1")},
],
"help_text": "Bad command test routine",
},
}
)
def test_malformed_routine(self):
with self.assertRaises(ImproperlyConfigured):
get_command("routine")
@override_settings(
DJANGO_ROUTINES={
"bad_command": {
"commands": [
{"command": ("track", "0")},
{"comand": ("track", "1")},
],
"help_text": "Bad command test routine",
"name": "bad_command",
},
}
)
def test_malformed_command(self):
with self.assertRaises(ImproperlyConfigured):
get_command("routine")
@override_settings(
DJANGO_ROUTINES={
"good": {
"commands": [
{"command": ("track", "0")},
{"command": ("track", "1")},
],
"help_text": "A good routine",
"name": "good",
},
}
)
def test_get_missing_routine(self):
self.assertEqual(get_routine("good").name, "good")
with self.assertRaises(KeyError):
get_routine("dne")
@override_settings(
DJANGO_ROUTINES={
"bad_command": {
"commands": [
{"command": ("track", "0")},
{"comand": ("track", "1")},
],
"help_text": "Bad command test routine",
"name": "bad_command",
},
}
)
def test_get_malformed_routine(self):
with self.assertRaises(ImproperlyConfigured):
get_routine("bad_command")
# why do these break everything??
# @override_settings(DJANGO_ROUTINES={})
# def test_no_routines(self):
# with self.assertRaises(CommandError):
# call_command("routine")
# @override_settings(DJANGO_ROUTINES=None)
# def test_routines_none(self):
# with self.assertRaises(CommandError):
# call_command("routine")