Commit 98409c5359b1f7dd3b7b901207752f14612369a4
1 parent
8238dbcf
Exists in
master
and in
5 other branches
[Test] Only professor and system admin can create and update a forum [Issues #99 and #103]
Showing
1 changed file
with
7 additions
and
11 deletions
Show diff stats
forum/tests/test_view_forum.py
@@ -158,7 +158,7 @@ class ForumViewTestCase (TestCase): | @@ -158,7 +158,7 @@ class ForumViewTestCase (TestCase): | ||
158 | self.assertEquals(response.status_code, 200) | 158 | self.assertEquals(response.status_code, 200) |
159 | 159 | ||
160 | response = self.client_student.get(url) | 160 | response = self.client_student.get(url) |
161 | - self.assertEquals(response.status_code, 200) | 161 | + self.assertEquals(response.status_code, 400) |
162 | 162 | ||
163 | def test_CreateForum_context(self): | 163 | def test_CreateForum_context(self): |
164 | url = reverse('course:forum:create') | 164 | url = reverse('course:forum:create') |
@@ -169,8 +169,6 @@ class ForumViewTestCase (TestCase): | @@ -169,8 +169,6 @@ class ForumViewTestCase (TestCase): | ||
169 | response = self.client_professor.get(url) | 169 | response = self.client_professor.get(url) |
170 | self.assertTrue('form' in response.context) | 170 | self.assertTrue('form' in response.context) |
171 | 171 | ||
172 | - response = self.client_student.get(url) | ||
173 | - self.assertTrue('form' in response.context) | ||
174 | 172 | ||
175 | def test_CreateForum_form_error (self): | 173 | def test_CreateForum_form_error (self): |
176 | url = reverse('course:forum:create') | 174 | url = reverse('course:forum:create') |
@@ -208,8 +206,8 @@ class ForumViewTestCase (TestCase): | @@ -208,8 +206,8 @@ class ForumViewTestCase (TestCase): | ||
208 | self.assertEquals(list_forum+2, Forum.objects.all().count()) | 206 | self.assertEquals(list_forum+2, Forum.objects.all().count()) |
209 | 207 | ||
210 | response = self.client_student.post(url, data) | 208 | response = self.client_student.post(url, data) |
211 | - self.assertEquals (response.status_code, 302) | ||
212 | - self.assertEquals(list_forum+3, Forum.objects.all().count()) | 209 | + self.assertEquals (response.status_code, 400) |
210 | + self.assertEquals(list_forum+2, Forum.objects.all().count()) | ||
213 | 211 | ||
214 | ######################### UpdateForumView ######################### | 212 | ######################### UpdateForumView ######################### |
215 | 213 | ||
@@ -223,7 +221,7 @@ class ForumViewTestCase (TestCase): | @@ -223,7 +221,7 @@ class ForumViewTestCase (TestCase): | ||
223 | self.assertEquals(response.status_code, 200) | 221 | self.assertEquals(response.status_code, 200) |
224 | 222 | ||
225 | response = self.client_student.get(url) | 223 | response = self.client_student.get(url) |
226 | - self.assertEquals(response.status_code, 200) | 224 | + self.assertEquals(response.status_code, 400) |
227 | 225 | ||
228 | 226 | ||
229 | def test_UpdateForum_context(self): | 227 | def test_UpdateForum_context(self): |
@@ -235,8 +233,6 @@ class ForumViewTestCase (TestCase): | @@ -235,8 +233,6 @@ class ForumViewTestCase (TestCase): | ||
235 | response = self.client_professor.get(url) | 233 | response = self.client_professor.get(url) |
236 | self.assertTrue('form' in response.context) | 234 | self.assertTrue('form' in response.context) |
237 | 235 | ||
238 | - response = self.client_student.get(url) | ||
239 | - self.assertTrue('form' in response.context) | ||
240 | 236 | ||
241 | def test_UpdateForum_form_error (self): | 237 | def test_UpdateForum_form_error (self): |
242 | url = reverse('course:forum:update', kwargs={'pk':self.forum.pk}) | 238 | url = reverse('course:forum:update', kwargs={'pk':self.forum.pk}) |
@@ -276,9 +272,9 @@ class ForumViewTestCase (TestCase): | @@ -276,9 +272,9 @@ class ForumViewTestCase (TestCase): | ||
276 | data['name'] = 'Forum Updated as student' | 272 | data['name'] = 'Forum Updated as student' |
277 | self.assertEquals(Forum.objects.all()[0].name, 'Forum Updated as professor') | 273 | self.assertEquals(Forum.objects.all()[0].name, 'Forum Updated as professor') |
278 | response = self.client_student.post(url, data) | 274 | response = self.client_student.post(url, data) |
279 | - self.assertEquals (response.status_code, 302) | ||
280 | - self.assertEquals(Forum.objects.all()[0].name, 'Forum Updated as student') | ||
281 | - forum = Forum.objects.get(name='Forum Updated as student') | 275 | + self.assertEquals (response.status_code, 400) |
276 | + self.assertNotEquals(Forum.objects.all()[0].name, 'Forum Updated as student') | ||
277 | + forum = Forum.objects.get(name='Forum Updated as professor') | ||
282 | 278 | ||
283 | ######################### CreatePostView ######################### | 279 | ######################### CreatePostView ######################### |
284 | 280 |