-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_mixins.py
More file actions
71 lines (60 loc) · 2.16 KB
/
test_mixins.py
File metadata and controls
71 lines (60 loc) · 2.16 KB
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
# =============================================================================
# IMPORTS
# =============================================================================
# Django
from django.test import TestCase
from django.views.generic import View
# App
from project_manager.mixins import DownloadMixin
# =============================================================================
# TEST CASES
# =============================================================================
class DownloadMixinTestCase(TestCase):
def test_view_inheritance(self):
self.assertTrue(
expr=issubclass(DownloadMixin, View),
)
def test_model_required(self):
obj = DownloadMixin()
with self.assertRaises(NotImplementedError) as context:
_ = obj.model
self.assertEqual(
first=str(context.exception),
second=(
f'Class "{obj.__class__.__name__}" must implement a '
f'"model" attribute.'
),
)
def test_base_url_required(self):
obj = DownloadMixin()
with self.assertRaises(NotImplementedError) as context:
_ = obj.base_url
self.assertEqual(
first=str(context.exception),
second=(
f'Class "{obj.__class__.__name__}" must implement a '
f'"base_url" attribute.'
),
)
def test_project_model_required(self):
obj = DownloadMixin()
with self.assertRaises(NotImplementedError) as context:
_ = obj.project_model
self.assertEqual(
first=str(context.exception),
second=(
f'Class "{obj.__class__.__name__}" must implement a '
f'"project_model" attribute.'
),
)
def test_model_kwarg_required(self):
obj = DownloadMixin()
with self.assertRaises(NotImplementedError) as context:
_ = obj.model_kwarg
self.assertEqual(
first=str(context.exception),
second=(
f'Class "{obj.__class__.__name__}" must implement a '
f'"model_kwarg" attribute.'
),
)