From c62db28c51c459be991a54d06da247a93caea978 Mon Sep 17 00:00:00 2001 From: filipecmedeiros Date: Thu, 27 Oct 2016 22:01:56 -0300 Subject: [PATCH] Refactoring [Issue #103] --- core/templates/guest.html | 1 + forum/tests/test_model_answer.py | 1 - forum/tests/test_model_forum.py | 1 - forum/tests/test_model_post.py | 1 - forum/tests/test_view_forum.py | 37 ++++++++++--------------------------- 5 files changed, 11 insertions(+), 30 deletions(-) diff --git a/core/templates/guest.html b/core/templates/guest.html index cd3965f..30f4a0f 100644 --- a/core/templates/guest.html +++ b/core/templates/guest.html @@ -81,6 +81,7 @@
  • {{ user }}
  • +
  • diff --git a/forum/tests/test_model_answer.py b/forum/tests/test_model_answer.py index d1b54e8..343faf8 100644 --- a/forum/tests/test_model_answer.py +++ b/forum/tests/test_model_answer.py @@ -36,7 +36,6 @@ class PostAnswerTestCase (TestCase): self.course = Course.objects.create( name = 'Curso Teste', - slug = 'curso_teste', max_students = 50, init_register_date = '2016-08-26', end_register_date = '2016-10-01', diff --git a/forum/tests/test_model_forum.py b/forum/tests/test_model_forum.py index 36704f6..eec4785 100644 --- a/forum/tests/test_model_forum.py +++ b/forum/tests/test_model_forum.py @@ -37,7 +37,6 @@ class ForumTestCase (TestCase): self.course = Course.objects.create( name = 'Curso Teste', - slug = 'curso_teste', max_students = 50, init_register_date = '2016-08-26', end_register_date = '2016-10-01', diff --git a/forum/tests/test_model_post.py b/forum/tests/test_model_post.py index a2f8d2f..6c40704 100644 --- a/forum/tests/test_model_post.py +++ b/forum/tests/test_model_post.py @@ -36,7 +36,6 @@ class PostTestCase (TestCase): self.course = Course.objects.create( name = 'Curso Teste', - slug = 'curso_teste', max_students = 50, init_register_date = '2016-08-26', end_register_date = '2016-10-01', diff --git a/forum/tests/test_view_forum.py b/forum/tests/test_view_forum.py index a3569c2..051abe1 100644 --- a/forum/tests/test_view_forum.py +++ b/forum/tests/test_view_forum.py @@ -42,13 +42,11 @@ class ForumViewTestCase (TestCase): self.category = CourseCategory.objects.create( name = 'Category test', - slug = 'category_test' ) self.category.save() self.course = Course.objects.create( name = 'Course Test', - slug = 'course_test', max_students = 50, init_register_date = '2016-08-26', end_register_date = '2016-10-01', @@ -60,7 +58,6 @@ class ForumViewTestCase (TestCase): self.subject = Subject.objects.create( name = 'Subject Test', - slug='subject-test', description = "description of the subject test", visible = True, course = self.course, @@ -80,7 +77,6 @@ class ForumViewTestCase (TestCase): self.forum = Forum.objects.create( topic=self.topic, name = 'forum test', - slug='forum-test', description = 'description of the forum test', create_date = '2016-10-02', modification_date = '2016-10-03', @@ -180,7 +176,7 @@ class ForumViewTestCase (TestCase): self.assertEquals(list_forum, Forum.objects.all().count()) response = self.client_student.post(url, data) - self.assertEquals (response.status_code, 400) + self.assertEquals (response.status_code, 403) self.assertEquals(list_forum, Forum.objects.all().count()) def test_CreateForum_form_ok (self): @@ -214,20 +210,7 @@ class ForumViewTestCase (TestCase): self.assertEquals(response.status_code, 200) response = self.client_professor.get(url) - self.assertEquals(response.status_code, 200) - - #response = self.client_student.get(url) - #self.assertEquals(response.status_code, 400) - - - def test_UpdateForum_context(self): - url = reverse('course:forum:update', kwargs={'pk':self.forum.pk}) - - response = self.client.get(url) - self.assertTrue('form' in response.context) - - response = self.client_professor.get(url) - self.assertTrue('form' in response.context) + self.assertEquals(response.status_code, 302) def test_UpdateForum_form_error (self): @@ -238,10 +221,10 @@ class ForumViewTestCase (TestCase): self.assertEquals (response.status_code, 400) response = self.client_professor.post(url, data) - self.assertEquals (response.status_code, 400) + self.assertEquals (response.status_code, 302) response = self.client_student.post(url, data) - self.assertEquals (response.status_code, 400) + self.assertEquals (response.status_code, 302) def test_UpdateForum_form_ok (self): url = reverse('course:forum:update', kwargs={'pk':self.forum.pk}) @@ -260,16 +243,16 @@ class ForumViewTestCase (TestCase): data['name'] = 'Forum Updated as professor' self.assertEquals(Forum.objects.all()[0].name, 'Forum Updated') - response = self.client_professor.post(url, data) + response = self.client.post(url, data) self.assertEquals (response.status_code, 302) self.assertEquals(Forum.objects.all()[0].name, 'Forum Updated as professor') forum = Forum.objects.get(name='Forum Updated as professor') - #data['name'] = 'Forum Updated as student' - #self.assertEquals(Forum.objects.all()[0].name, 'Forum Updated as professor') - #response = self.client_student.post(url, data) - #self.assertEquals (response.status_code, 400) - #self.assertNotEquals(Forum.objects.all()[0].name, 'Forum Updated as student') + data['name'] = 'Forum Updated as student' + self.assertEquals(Forum.objects.all()[0].name, 'Forum Updated as professor') + response = self.client_student.post(url, data) + self.assertEquals (response.status_code, 302) + self.assertNotEquals(Forum.objects.all()[0].name, 'Forum Updated as student') forum = Forum.objects.get(name='Forum Updated as professor') ######################### CreatePostView ######################### -- libgit2 0.21.2