summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCruiseDevice2020-09-08 17:19:05 +0530
committerankitjavalkar2020-10-08 10:40:08 +0530
commit9ee0aed71778236917e5ef0738f991836a22445c (patch)
tree27c45d8c144c4d60db4f00cb0fa9391708f30db9
parent25cb22481469f738d6aa9ed440474f34e22600aa (diff)
downloadonline_test-9ee0aed71778236917e5ef0738f991836a22445c.tar.gz
online_test-9ee0aed71778236917e5ef0738f991836a22445c.tar.bz2
online_test-9ee0aed71778236917e5ef0738f991836a22445c.zip
Fix Tests
-rw-r--r--yaksh/test_views.py40
1 files changed, 15 insertions, 25 deletions
diff --git a/yaksh/test_views.py b/yaksh/test_views.py
index 9cb454e..6b74096 100644
--- a/yaksh/test_views.py
+++ b/yaksh/test_views.py
@@ -22,6 +22,7 @@ from django.conf import settings
from django.core.files.uploadedfile import SimpleUploadedFile
from django.core.files import File
from django.contrib.messages import get_messages
+from django.contrib.contenttypes.models import ContentType
from celery.contrib.testing.worker import start_worker
from django.test import SimpleTestCase
@@ -6851,10 +6852,11 @@ class TestPost(TestCase):
url = reverse('yaksh:course_forum', kwargs={
'course_id': self.course.id
})
+ course_ct = ContentType.objects.get_for_model(self.course)
post = Post.objects.create(
title='post 1',
description='post 1 description',
- course=self.course,
+ target_ct=course_ct, target_id=self.course.id,
creator=self.student
)
response = self.client.get(url)
@@ -6879,9 +6881,11 @@ class TestPost(TestCase):
}
response = self.client.post(url, data)
# This shouldn't be 302. Check where does it redirects.
+ course_ct = ContentType.objects.get_for_model(self.course)
result = Post.objects.filter(title='Post 1',
creator=self.student,
- course=self.course)
+ target_ct=course_ct,
+ target_id=self.course.id)
self.assertTrue(result.exists())
def test_new_post_invalid_post_data(self):
@@ -6914,24 +6918,12 @@ class TestPost(TestCase):
self.assertEquals(response.status_code, 200)
self.assertFalse(Post.objects.exists())
- def test_contains_form(self):
- self.client.login(
- username=self.student.username,
- password=self.student_plaintext_pass
- )
- self.course.students.add(self.student)
- url = reverse('yaksh:course_forum', kwargs={
- 'course_id': self.course.id
- })
- response = self.client.get(url)
- form = response.context.get('form')
- self.assertIsInstance(form, PostForm)
-
def test_open_created_post_denies_anonymous_user(self):
+ course_ct = ContentType.objects.get_for_model(self.course)
post = Post.objects.create(
title='post 1',
description='post 1 description',
- course=self.course,
+ target_ct=course_ct, target_id=self.course.id,
creator=self.student
)
url = reverse('yaksh:post_comments', kwargs={
@@ -6970,23 +6962,22 @@ class TestPost(TestCase):
password=self.user_plaintext_pass
)
self.course.students.add(self.user)
+ course_ct = ContentType.objects.get_for_model(self.course)
post = Post.objects.create(
title='post 1',
description='post 1 description',
- course=self.course,
- creator=self.user
+ target_ct=course_ct, target_id=self.course.id,
+ creator=self.student
)
url = reverse('yaksh:hide_post', kwargs={
'course_id': self.course.id,
'uuid': post.uid
})
response = self.client.get(url, follow=True)
- self.assertEqual(response.status_code, 200)
+ self.assertEqual(response.status_code, 404)
def tearDown(self):
self.client.logout()
- self.user.delete()
- self.course.delete()
self.mod_group.delete()
@@ -7037,10 +7028,11 @@ class TestPostComment(TestCase):
enrollment="Enroll Request", creator=self.user
)
+ course_ct = ContentType.objects.get_for_model(self.course)
self.post = Post.objects.create(
title='post 1',
description='post 1 description',
- course=self.course,
+ target_ct=course_ct, target_id=self.course.id,
creator=self.student
)
@@ -7204,12 +7196,10 @@ class TestPostComment(TestCase):
'uuid': comment.uid
})
response = self.client.get(url)
- self.assertEquals(response.status_code, 302)
+ self.assertEquals(response.status_code, 404)
def tearDown(self):
self.client.logout()
- self.user.delete()
- self.course.delete()
self.mod_group.delete()