summaryrefslogtreecommitdiff
path: root/yaksh/test_models.py
diff options
context:
space:
mode:
authorCruiseDevice2019-02-18 15:30:55 +0530
committerCruiseDevice2019-02-18 15:30:55 +0530
commitf0314d106a6402421315873a95dda38c4eef4adf (patch)
treed9d173c3681b9f8bb55bc95beb2dc5abd8d25a2b /yaksh/test_models.py
parent31336af1487201b05681c039c839a9213143fcf2 (diff)
downloadonline_test-f0314d106a6402421315873a95dda38c4eef4adf.tar.gz
online_test-f0314d106a6402421315873a95dda38c4eef4adf.tar.bz2
online_test-f0314d106a6402421315873a95dda38c4eef4adf.zip
Add TestCase for get_filename() of FileUpload model
Diffstat (limited to 'yaksh/test_models.py')
-rw-r--r--yaksh/test_models.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/yaksh/test_models.py b/yaksh/test_models.py
index 1f38d03..53ee656 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.core.files.uploadedfile import SimpleUploadedFile
from yaksh.models import User, Profile, Question, Quiz, QuestionPaper,\
QuestionSet, AnswerPaper, Answer, Course, StandardTestCase,\
StdIOBasedTestCase, FileUpload, McqTestCase, AssignmentUpload,\
@@ -2130,3 +2131,22 @@ class CourseStatusTestCases(unittest.TestCase):
# Test get course grade after completion
self.assertEqual(self.course.get_grade(self.answerpaper1.user), 'B')
+
+
+class FileUploadTestCases(unittest.TestCase):
+ def setUp(self):
+ self.question = Question.objects.get(summary='Q1')
+ self.filename = "uploadtest.txt"
+ self.uploaded_file = SimpleUploadedFile(self.filename, b'Test File')
+ self.file_upload = FileUpload.objects.create(
+ file=self.uploaded_file,
+ question=self.question
+ )
+
+ def test_get_file_name(self):
+ print((self.file_upload.file.path))
+ self.assertEqual(self.file_upload.get_filename(), self.filename)
+
+ def tearDown(self):
+ os.remove(self.file_upload.file.path)
+ self.file_upload.delete()