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 | 78 | |
79 | 79 | def test_create_forum (self): |
80 | 80 | list_forum = Forum.objects.all().count() |
81 | - | |
82 | - forum = Forum.objects.create( | |
81 | + | |
82 | + forum = Forum.objects.create( | |
83 | 83 | topic=self.topic, |
84 | 84 | name = 'forum test2', |
85 | 85 | description = 'description of the forum test', |
... | ... | @@ -87,9 +87,9 @@ class ForumTestCase (TestCase): |
87 | 87 | modification_date = '2016-10-03', |
88 | 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 | 94 | def test_update_forum(self): |
95 | 95 | list_forum = Forum.objects.all().count() | ... | ... |
forum/tests/test_model_post.py
... | ... | @@ -94,6 +94,8 @@ class PostTestCase (TestCase): |
94 | 94 | self.post_student.save() |
95 | 95 | |
96 | 96 | def test_create_post_professor (self): |
97 | + list_post = Post.objects.all().count() | |
98 | + | |
97 | 99 | post_professor = Post.objects.create( |
98 | 100 | user = self.user_professor, |
99 | 101 | message = 'posting', |
... | ... | @@ -103,9 +105,11 @@ class PostTestCase (TestCase): |
103 | 105 | ) |
104 | 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 | 110 | def test_create_post_student (self): |
111 | + list_post = Post.objects.all().count() | |
112 | + | |
109 | 113 | post_student = Post.objects.create( |
110 | 114 | user = self.user_student, |
111 | 115 | message = 'posting', |
... | ... | @@ -115,34 +119,35 @@ class PostTestCase (TestCase): |
115 | 119 | ) |
116 | 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 | 124 | def test_update_post_professor (self): |
125 | + list_post = Post.objects.all().count() | |
121 | 126 | self.post_professor.message = 'updating a post as professor' |
122 | 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 | 132 | def test_update_post_student (self): |
133 | + list_post = Post.objects.all().count() | |
127 | 134 | self.post_student.message = 'updating a post as student' |
128 | 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 | 140 | def test_delete_post_professor (self): |
141 | + list_post = Post.objects.all().count() | |
142 | + | |
133 | 143 | post = Post.objects.get(user=self.user_professor, message='posting a test on forum as professor') |
134 | 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 | 148 | def test_delete_post_student (self): |
149 | + list_post = Post.objects.all().count() | |
142 | 150 | post = Post.objects.get(user=self.user_student, message='posting a test on forum as student') |
143 | 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 | 153 | \ No newline at end of file |
154 | + self.assertEquals(list_post-1, Post.objects.all().count()) | |
150 | 155 | \ No newline at end of file | ... | ... |