diff options
author | CruiseDevice | 2019-02-18 15:30:55 +0530 |
---|---|---|
committer | CruiseDevice | 2019-02-18 15:30:55 +0530 |
commit | f0314d106a6402421315873a95dda38c4eef4adf (patch) | |
tree | d9d173c3681b9f8bb55bc95beb2dc5abd8d25a2b | |
parent | 31336af1487201b05681c039c839a9213143fcf2 (diff) | |
download | online_test-f0314d106a6402421315873a95dda38c4eef4adf.tar.gz online_test-f0314d106a6402421315873a95dda38c4eef4adf.tar.bz2 online_test-f0314d106a6402421315873a95dda38c4eef4adf.zip |
Add TestCase for get_filename() of FileUpload model
-rw-r--r-- | yaksh/test_models.py | 20 |
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() |