@@ -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
124126class 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
129139class 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