Allow drawing once every day
The duration between two draws is controlled by settings.DRAW_TIME
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
from datetime import timedelta
|
||||
from django.conf import settings
|
||||
from django.contrib.auth.models import User
|
||||
from django.core.exceptions import ValidationError
|
||||
from django.utils import timezone
|
||||
from django.utils.dateparse import parse_duration
|
||||
from django.utils.translation import activate
|
||||
from django.test import TestCase
|
||||
|
||||
@@ -80,6 +82,8 @@ class DrawTest(TestCase):
|
||||
accepted=None)
|
||||
self.assertEquals(self.word, self.user.draw_word())
|
||||
draw.accepted = True
|
||||
duration = parse_duration(settings.DRAW_TIME)
|
||||
draw.timestamp -= 2 * duration
|
||||
draw.save()
|
||||
Work.objects.create(draw=draw)
|
||||
|
||||
@@ -91,6 +95,7 @@ class DrawTest(TestCase):
|
||||
self.assertIsNone(draw.accepted)
|
||||
|
||||
draw.accepted = True
|
||||
draw.timestamp -= 2 * duration
|
||||
draw.save()
|
||||
Work.objects.create(draw=draw)
|
||||
|
||||
@@ -110,3 +115,12 @@ class DrawTest(TestCase):
|
||||
Work.objects.create(draw=draw)
|
||||
|
||||
self.assertEquals(word, self.user.last_draw().word)
|
||||
|
||||
def test_draw_per_day(self):
|
||||
draw = Draw.objects.create(user=self.user,
|
||||
word=self.word,
|
||||
accepted=True)
|
||||
Work.objects.create(draw=draw)
|
||||
Word.objects.create()
|
||||
|
||||
self.assertEquals(self.word, self.user.draw_word())
|
||||
|
Reference in New Issue
Block a user