Commit 0a244854e09c138be40451bb0254310b9c3423e5
1 parent
391ca499
Exists in
master
and in
5 other branches
Adding test create forum [Issue #87 and #99]
Showing
4 changed files
with
81 additions
and
3 deletions
Show diff stats
forum/models.py
forum/tests.py
| ... | ... | @@ -0,0 +1,80 @@ |
| 1 | +from django.test import TestCase, Client | |
| 2 | +from django.core.urlresolvers import reverse | |
| 3 | +from rolepermissions.shortcuts import assign_role | |
| 4 | + | |
| 5 | +from users.models import User | |
| 6 | +from courses.models import Category, Course, Subject, Topic | |
| 7 | +from forum.models import Forum | |
| 8 | + | |
| 9 | +class ForumTestCase (TestCase): | |
| 10 | + | |
| 11 | + def setUp(self): | |
| 12 | + self.user_professor = User.objects.create_user( | |
| 13 | + username = 'professor', | |
| 14 | + email = 'professor@amadeus.com', | |
| 15 | + is_staff = False, | |
| 16 | + is_active = True, | |
| 17 | + password = 'testing', | |
| 18 | + type_profile = 1 | |
| 19 | + ) | |
| 20 | + assign_role(self.user_professor, 'professor') | |
| 21 | + | |
| 22 | + self.user_student = User.objects.create_user( | |
| 23 | + username = 'student', | |
| 24 | + email = 'student@amadeus.com', | |
| 25 | + is_staff = False, | |
| 26 | + is_active = True, | |
| 27 | + password = 'testing', | |
| 28 | + type_profile = 2 | |
| 29 | + ) | |
| 30 | + assign_role(self.user_student, 'student') | |
| 31 | + | |
| 32 | + self.category = Category.objects.create( | |
| 33 | + name = 'Categoria Teste', | |
| 34 | + slug = 'categoria_teste' | |
| 35 | + ) | |
| 36 | + self.category.save() | |
| 37 | + | |
| 38 | + self.course = Course.objects.create( | |
| 39 | + name = 'Curso Teste', | |
| 40 | + slug = 'curso_teste', | |
| 41 | + max_students = 50, | |
| 42 | + init_register_date = '2016-08-26', | |
| 43 | + end_register_date = '2016-10-01', | |
| 44 | + init_date = '2016-10-05', | |
| 45 | + end_date = '2017-10-05', | |
| 46 | + category = self.category | |
| 47 | + ) | |
| 48 | + self.course.save() | |
| 49 | + | |
| 50 | + self.subject = Subject.objects.create( | |
| 51 | + name = 'Subject Test', | |
| 52 | + description = "description of the subject test", | |
| 53 | + visible = True, | |
| 54 | + course = self.course, | |
| 55 | + init_date = '2016-10-05', | |
| 56 | + end_date = '2017-10-05', | |
| 57 | + ) | |
| 58 | + self.subject.save() | |
| 59 | + self.subject.professors.add(self.user_professor) | |
| 60 | + | |
| 61 | + self.topic = Topic.objects.create( | |
| 62 | + name = 'Topic Test', | |
| 63 | + description = "description of the topic test", | |
| 64 | + subject = self.subject, | |
| 65 | + owner = self.user_professor, | |
| 66 | + ) | |
| 67 | + self.topic.save() | |
| 68 | + | |
| 69 | + def test_create_forum (self): | |
| 70 | + forum = Forum.objects.create( | |
| 71 | + topic=self.topic, | |
| 72 | + name = 'forum test', | |
| 73 | + description = 'description of the forum test', | |
| 74 | + create_date = '2016-10-02', | |
| 75 | + modification_date = '2016-10-03', | |
| 76 | + limit_date = '2017-10-05', | |
| 77 | + ) | |
| 78 | + forum.save() | |
| 79 | + | |
| 80 | + self.assertEquals(forum, Forum.objects.all()[0]) | |
| 0 | 81 | \ No newline at end of file | ... | ... |