Skip to content

Commit 7108e18

Browse files
committed
Issue #25: More test cases
1 parent bc3c64e commit 7108e18

File tree

1 file changed

+27
-8
lines changed

1 file changed

+27
-8
lines changed

tests/test_context_view.py

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -116,15 +116,25 @@ def get_data(self):
116116
}
117117

118118

119-
class EmptyModelContext(views.ContextView):
120-
"""Badly initiated context."""
121-
pass
119+
class ModelUndefinedContext(views.ContextView):
120+
"""Model undefined"""
121+
122+
def get_data(self):
123+
pass
122124

123125

124126
class WrongModelContext(views.ContextView):
125-
"""Badly initiated context."""
127+
"""Wrong model defined."""
126128
__model__ = type
127129

130+
def get_data(self):
131+
pass
132+
133+
134+
class GetterUndefinedContext(views.ContextView):
135+
"""Getter undefined."""
136+
__model__ = Profile
137+
128138

129139
class TestContextView(unittest.TestCase):
130140
main_photo = Photo(id=1, title='main photo', path='path/to/the/main/photo',
@@ -141,14 +151,23 @@ class TestContextView(unittest.TestCase):
141151
main_photo=main_photo,
142152
photos=[main_photo, photo2, photo3])
143153

144-
def test_wrong_class_defined(self):
145-
with self.assertRaises(TypeError):
146-
EmptyModelContext("it doesn't matter")
147-
148154
def test_wrong_model_passed(self):
149155
with self.assertRaises(TypeError):
150156
PublicProfile("invalid argument")
151157

158+
def test_model_undefined(self):
159+
with self.assertRaises(TypeError):
160+
ModelUndefinedContext("it doesn't matter")
161+
162+
def test_wrong_model_defined(self):
163+
with self.assertRaises(TypeError):
164+
WrongModelContext("it doesn't matter")
165+
166+
def test_getter_undefined(self):
167+
contextual_view = GetterUndefinedContext(self.profile)
168+
with self.assertRaises(NotImplementedError):
169+
contextual_view.get_data()
170+
152171
def test_context_view(self):
153172
public_context = PublicProfile(self.profile)
154173
private_context = PrivateProfile(self.profile)

0 commit comments

Comments
 (0)