-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_models.py
More file actions
53 lines (45 loc) · 1.66 KB
/
test_models.py
File metadata and controls
53 lines (45 loc) · 1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import django.test
import business.constants
import business.models
class CompanyModelTests(django.test.TestCase):
def test_company_str_representation(self):
company = business.models.Company.objects.create(
email='contact@company.com',
name='My Awesome Company',
)
self.assertEqual(str(company), 'My Awesome Company')
class PromoModelTests(django.test.TestCase):
def setUp(self):
self.company = business.models.Company.objects.create(
email='company@test.com',
name='TestCorp',
)
self.common_promo = business.models.Promo.objects.create(
company=self.company,
description='A common promo',
max_count=100,
used_count=50,
mode=business.constants.PROMO_MODE_COMMON,
)
def test_promo_str_representation(self):
expected_str = (
f'Promo {self.common_promo.id} ({self.common_promo.mode})'
)
self.assertEqual(str(self.common_promo), expected_str)
class PromoCodeModelTests(django.test.TestCase):
def test_promo_code_str_representation(self):
company = business.models.Company.objects.create(
email='company@test.com',
name='TestCorp',
)
promo = business.models.Promo.objects.create(
company=company,
description='Unique codes promo',
max_count=10,
mode=business.constants.PROMO_MODE_UNIQUE,
)
promo_code = business.models.PromoCode.objects.create(
promo=promo,
code='UNIQUE123',
)
self.assertEqual(str(promo_code), 'UNIQUE123')