reverend
547179b0ca
commit 97b044cafb7f17f23b3b1beedcf70af209a60ddc Author: reverend <reverend@reverend2048.de> Date: Mon Sep 14 17:25:40 2020 +0200 Updating gitignore commit 4891d80486e1f95db8ae66385c7c97426a3ca1a4 Author: reverend <reverend@reverend2048.de> Date: Mon Sep 14 17:25:20 2020 +0200 Updating Readme commit f05c43abbdc7eb30896ad6d10fe80fd6483338d9 Author: reverend <reverend@reverend2048.de> Date: Mon Sep 14 17:23:30 2020 +0200 Renaming Module commit fd5ad2ee9f8cbacd565da45b257928192ffc651c Author: reverend <reverend@reverend2048.de> Date: Mon Sep 14 17:23:16 2020 +0200 Renaming module references commit 828a0dd5dd73723b84b77908497903ed26b6966b Author: reverend <reverend@reverend2048.de> Date: Mon Sep 14 17:21:20 2020 +0200 Renaming Project
53 lines
1.4 KiB
Python
53 lines
1.4 KiB
Python
import datetime
|
|
|
|
from django.test import TestCase
|
|
from django.db import models
|
|
from django.utils import timezone
|
|
|
|
from lostplaces.models import Voucher
|
|
from lostplaces.tests.models import ModelTestCase
|
|
|
|
|
|
class VoucheTestCase(ModelTestCase):
|
|
model = Voucher
|
|
|
|
@classmethod
|
|
def setUpTestData(cls):
|
|
Voucher.objects.create(
|
|
code='ayDraJCCwfhcFiYmSR5GrcjcchDfcahv',
|
|
expires_when=timezone.now() + datetime.timedelta(days=1)
|
|
)
|
|
|
|
def setUp(self):
|
|
self.voucher = Voucher.objects.get(id=1)
|
|
|
|
def test_voucher_code(self):
|
|
self.assertCharField(
|
|
field_name='code',
|
|
min_length=10,
|
|
max_length=100,
|
|
must_have={'unique': True}
|
|
)
|
|
|
|
def test_voucher_created(self):
|
|
self.assertField(
|
|
field_name='created_when',
|
|
field_class=models.DateTimeField,
|
|
must_have={'auto_now_add': True}
|
|
)
|
|
|
|
def test_voucher_expires(self):
|
|
self.assertField(
|
|
field_name='expires_when',
|
|
field_class=models.DateTimeField,
|
|
must_not_have={'auto_now_add': True}
|
|
)
|
|
|
|
def test_str(self):
|
|
self.assertTrue(
|
|
self.voucher.code.lower() in str(self.voucher).lower(),
|
|
msg='Expecting %s.__str__ to contain the voucher code' % (
|
|
self.model.__name__
|
|
)
|
|
)
|