Commit 1b3a4c820ce564d002235efe0ff26ebcb245036e
Exists in
master
and in
5 other branches
Merge branch 'dev' of https://github.com/amadeusproject/amadeuslms into dev
Showing
2 changed files
with
21 additions
and
16 deletions
Show diff stats
forum/tests/test_model_forum.py
@@ -78,8 +78,8 @@ class ForumTestCase (TestCase): | @@ -78,8 +78,8 @@ class ForumTestCase (TestCase): | ||
78 | 78 | ||
79 | def test_create_forum (self): | 79 | def test_create_forum (self): |
80 | list_forum = Forum.objects.all().count() | 80 | list_forum = Forum.objects.all().count() |
81 | - | ||
82 | - forum = Forum.objects.create( | 81 | + |
82 | + forum = Forum.objects.create( | ||
83 | topic=self.topic, | 83 | topic=self.topic, |
84 | name = 'forum test2', | 84 | name = 'forum test2', |
85 | description = 'description of the forum test', | 85 | description = 'description of the forum test', |
@@ -87,9 +87,9 @@ class ForumTestCase (TestCase): | @@ -87,9 +87,9 @@ class ForumTestCase (TestCase): | ||
87 | modification_date = '2016-10-03', | 87 | modification_date = '2016-10-03', |
88 | limit_date = '2017-10-05', | 88 | limit_date = '2017-10-05', |
89 | ) | 89 | ) |
90 | - forum.save() | 90 | + forum.save() |
91 | 91 | ||
92 | - self.assertEquals(list_forum+1, Forum.objects.all().count()) | 92 | + self.assertEquals(list_forum+1, Forum.objects.all().count()) |
93 | 93 | ||
94 | def test_update_forum(self): | 94 | def test_update_forum(self): |
95 | list_forum = Forum.objects.all().count() | 95 | list_forum = Forum.objects.all().count() |
forum/tests/test_model_post.py
@@ -94,6 +94,8 @@ class PostTestCase (TestCase): | @@ -94,6 +94,8 @@ class PostTestCase (TestCase): | ||
94 | self.post_student.save() | 94 | self.post_student.save() |
95 | 95 | ||
96 | def test_create_post_professor (self): | 96 | def test_create_post_professor (self): |
97 | + list_post = Post.objects.all().count() | ||
98 | + | ||
97 | post_professor = Post.objects.create( | 99 | post_professor = Post.objects.create( |
98 | user = self.user_professor, | 100 | user = self.user_professor, |
99 | message = 'posting', | 101 | message = 'posting', |
@@ -103,9 +105,11 @@ class PostTestCase (TestCase): | @@ -103,9 +105,11 @@ class PostTestCase (TestCase): | ||
103 | ) | 105 | ) |
104 | post_professor.save() | 106 | post_professor.save() |
105 | 107 | ||
106 | - self.assertEquals (post_professor, Post.objects.get(user=self.user_professor, message='posting')) | 108 | + self.assertEquals(list_post+1, Post.objects.all().count()) |
107 | 109 | ||
108 | def test_create_post_student (self): | 110 | def test_create_post_student (self): |
111 | + list_post = Post.objects.all().count() | ||
112 | + | ||
109 | post_student = Post.objects.create( | 113 | post_student = Post.objects.create( |
110 | user = self.user_student, | 114 | user = self.user_student, |
111 | message = 'posting', | 115 | message = 'posting', |
@@ -115,34 +119,35 @@ class PostTestCase (TestCase): | @@ -115,34 +119,35 @@ class PostTestCase (TestCase): | ||
115 | ) | 119 | ) |
116 | post_student.save() | 120 | post_student.save() |
117 | 121 | ||
118 | - self.assertEquals (post_student, Post.objects.get(user=self.user_student, message='posting')) | 122 | + self.assertEquals(list_post+1, Post.objects.all().count()) |
119 | 123 | ||
120 | def test_update_post_professor (self): | 124 | def test_update_post_professor (self): |
125 | + list_post = Post.objects.all().count() | ||
121 | self.post_professor.message = 'updating a post as professor' | 126 | self.post_professor.message = 'updating a post as professor' |
122 | self.post_professor.save() | 127 | self.post_professor.save() |
123 | 128 | ||
124 | - self.assertEquals(self.post_professor, Post.objects.all()[1]) | 129 | + self.assertEquals(self.post_professor, Post.objects.get(message='updating a post as professor')) |
130 | + self.assertEquals(list_post, Post.objects.all().count()) | ||
125 | 131 | ||
126 | def test_update_post_student (self): | 132 | def test_update_post_student (self): |
133 | + list_post = Post.objects.all().count() | ||
127 | self.post_student.message = 'updating a post as student' | 134 | self.post_student.message = 'updating a post as student' |
128 | self.post_student.save() | 135 | self.post_student.save() |
129 | 136 | ||
130 | - self.assertEquals(self.post_student, Post.objects.all()[1]) | 137 | + self.assertEquals(self.post_student, Post.objects.get(message='updating a post as student')) |
138 | + self.assertEquals(list_post, Post.objects.all().count()) | ||
131 | 139 | ||
132 | def test_delete_post_professor (self): | 140 | def test_delete_post_professor (self): |
141 | + list_post = Post.objects.all().count() | ||
142 | + | ||
133 | post = Post.objects.get(user=self.user_professor, message='posting a test on forum as professor') | 143 | post = Post.objects.get(user=self.user_professor, message='posting a test on forum as professor') |
134 | self.post_professor.delete() | 144 | self.post_professor.delete() |
135 | 145 | ||
136 | - try: | ||
137 | - post = Post.objects.get(user=self.user_professor, message='posting a test on forum as professor') | ||
138 | - except: | ||
139 | - pass | 146 | + self.assertEquals(list_post-1, Post.objects.all().count()) |
140 | 147 | ||
141 | def test_delete_post_student (self): | 148 | def test_delete_post_student (self): |
149 | + list_post = Post.objects.all().count() | ||
142 | post = Post.objects.get(user=self.user_student, message='posting a test on forum as student') | 150 | post = Post.objects.get(user=self.user_student, message='posting a test on forum as student') |
143 | self.post_student.delete() | 151 | self.post_student.delete() |
144 | 152 | ||
145 | - try: | ||
146 | - post = Post.objects.get(user=self.user_student, message='posting a test on forum as student') | ||
147 | - except: | ||
148 | - pass | ||
149 | \ No newline at end of file | 153 | \ No newline at end of file |
154 | + self.assertEquals(list_post-1, Post.objects.all().count()) | ||
150 | \ No newline at end of file | 155 | \ No newline at end of file |