From 4d87a5eec1af36d32cc0daa4b6c1053a62712b7a Mon Sep 17 00:00:00 2001 From: CruiseDevice Date: Thu, 10 Sep 2020 20:11:53 +0530 Subject: Fix breaking tests in test_models --- yaksh/test_models.py | 51 +++------------------------------------------------ yaksh/test_views.py | 4 ++++ 2 files changed, 7 insertions(+), 48 deletions(-) diff --git a/yaksh/test_models.py b/yaksh/test_models.py index cd8776b..67da7d1 100644 --- a/yaksh/test_models.py +++ b/yaksh/test_models.py @@ -1,5 +1,6 @@ import unittest from django.contrib.auth.models import Group +from django.contrib.contenttypes.models import ContentType from django.core.files.uploadedfile import SimpleUploadedFile from yaksh.models import User, Profile, Question, Quiz, QuestionPaper,\ QuestionSet, AnswerPaper, Answer, Course, StandardTestCase,\ @@ -2431,9 +2432,10 @@ class PostModelTestCases(unittest.TestCase): enrollment='Enroll Request', creator=self.user3 ) + course_ct = ContentType.objects.get_for_model(self.course) self.post1 = Post.objects.create( title='Post 1', - course=self.course, + target_ct=course_ct, target_id=self.course.id, creator=self.user1, description='Post 1 description' ) @@ -2456,56 +2458,9 @@ class PostModelTestCases(unittest.TestCase): count = self.post1.get_comments_count() self.assertEquals(count, 2) - def test__str__(self): - self.assertEquals(str(self.post1.title), self.post1.title) - def tearDown(self): self.user1.delete() self.user2.delete() self.user3.delete() self.course.delete() self.post1.delete() - - -class CommentModelTestCases(unittest.TestCase): - def setUp(self): - self.user1 = User.objects.create( - username='bart', - password='bart', - email='bart@test.com' - ) - Profile.objects.create( - user=self.user1, - roll_number=1, - institute='IIT', - department='Chemical', - position='Student' - ) - self.course = Course.objects.create( - name='Python Course', - enrollment='Enroll Request', - creator=self.user1 - ) - self.post1 = Post.objects.create( - title='Post 1', - course=self.course, - creator=self.user1, - description='Post 1 description' - ) - self.comment1 = Comment.objects.create( - post_field=self.post1, - creator=self.user1, - description='Post 1 comment 1' - ) - - def test__str__(self): - self.assertEquals( - str(self.comment1.post_field.title), - self.comment1.post_field.title - ) - - def tearDown(self): - self.user1.delete() - self.course.delete() - self.post1.delete() - self.comment1.delete() diff --git a/yaksh/test_views.py b/yaksh/test_views.py index 6b74096..906f2e3 100644 --- a/yaksh/test_views.py +++ b/yaksh/test_views.py @@ -6978,6 +6978,8 @@ class TestPost(TestCase): def tearDown(self): self.client.logout() + self.user.delete() + self.course.delete() self.mod_group.delete() @@ -7200,6 +7202,8 @@ class TestPostComment(TestCase): def tearDown(self): self.client.logout() + self.user.delete() + self.course.delete() self.mod_group.delete() -- cgit