diff options
author | Prabhu Ramachandran | 2016-07-05 09:58:51 -0400 |
---|---|---|
committer | GitHub | 2016-07-05 09:58:51 -0400 |
commit | c8dfe62663d715dcf4b571c1f738428165734d2a (patch) | |
tree | 71c7280c92fed8981f4e4df4c8b5ddfd6716ed33 /yaksh/tests.py | |
parent | 660a8b4f8b21a1e5836536a9db755fcf840ecd63 (diff) | |
parent | e46028c511596e52495d64baed6fc53e11fb3b4a (diff) | |
download | online_test-c8dfe62663d715dcf4b571c1f738428165734d2a.tar.gz online_test-c8dfe62663d715dcf4b571c1f738428165734d2a.tar.bz2 online_test-c8dfe62663d715dcf4b571c1f738428165734d2a.zip |
Merge pull request #106 from adityacp/fix_timezone
Fix timezone
Diffstat (limited to 'yaksh/tests.py')
-rw-r--r-- | yaksh/tests.py | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/yaksh/tests.py b/yaksh/tests.py index f2083dd..e71a78f 100644 --- a/yaksh/tests.py +++ b/yaksh/tests.py @@ -4,6 +4,8 @@ from yaksh.models import User, Profile, Question, Quiz, QuestionPaper,\ StdoutBasedTestCase import json from datetime import datetime, timedelta +from django.utils import timezone +import pytz from django.contrib.auth.models import Group def setUpModule(): @@ -31,16 +33,20 @@ def setUpModule(): Question.objects.create(summary='Q%d' % (i), points=1, type='code', user=user) # create a quiz - quiz = Quiz.objects.create(start_date_time=datetime(2015, 10, 9, 10, 8, 15, 0), - end_date_time=datetime(2199, 10, 9, 10, 8, 15, 0), + quiz = Quiz.objects.create(start_date_time=datetime(2015, 10, 9, 10, 8, 15, 0, + tzinfo=pytz.utc), + end_date_time=datetime(2199, 10, 9, 10, 8, 15, 0, + tzinfo=pytz.utc), duration=30, active=True, attempts_allowed=1, time_between_attempts=0, description='demo quiz', pass_criteria=0, language='Python', prerequisite=None, course=course) - Quiz.objects.create(start_date_time=datetime(2014, 10, 9, 10, 8, 15, 0), - end_date_time=datetime(2015, 10, 9, 10, 8, 15, 0), + Quiz.objects.create(start_date_time=datetime(2014, 10, 9, 10, 8, 15, 0, + tzinfo=pytz.utc), + end_date_time=datetime(2015, 10, 9, 10, 8, 15, 0, + tzinfo=pytz.utc), duration=30, active=False, attempts_allowed=-1, time_between_attempts=0, description='demo quiz', pass_criteria=40, @@ -303,7 +309,7 @@ class AnswerPaperTestCases(unittest.TestCase): self.question_paper = QuestionPaper(quiz=self.quiz, total_marks=3) self.question_paper.save() self.questions = Question.objects.filter(id__in=[1,2,3]) - self.start_time = datetime.now() + self.start_time = timezone.now() self.end_time = self.start_time + timedelta(minutes=20) # create answerpaper @@ -386,7 +392,7 @@ class AnswerPaperTestCases(unittest.TestCase): self.assertFalse(self.answerpaper.is_attempt_inprogress()) def test_set_end_time(self): - current_time = datetime.now() + current_time = timezone.now() self.answerpaper.set_end_time(current_time) self.assertEqual(self.answerpaper.end_time,current_time) |