-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbase.py
More file actions
74 lines (65 loc) · 2.34 KB
/
base.py
File metadata and controls
74 lines (65 loc) · 2.34 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import django.urls
import rest_framework.test
import business.models
import user.models
class BasePromoTestCase(rest_framework.test.APITestCase):
@classmethod
def setUpTestData(cls):
super().setUpTestData()
cls.client = rest_framework.test.APIClient()
cls.promo_list_create_url = django.urls.reverse(
'api-business:promo-list-create',
)
cls.company_signup_url = django.urls.reverse(
'api-business:company-sign-up',
)
cls.company_signin_url = django.urls.reverse(
'api-business:company-sign-in',
)
cls.company1_data = {
'name': 'Digital Marketing Solutions Inc.',
'email': 'company1@example.com',
'password': 'SecurePass123!',
}
business.models.Company.objects.create_company(**cls.company1_data)
cls.company1 = business.models.Company.objects.get(
email=cls.company1_data['email'],
)
cls.company2_data = {
'name': 'Global Retail Hub LLC',
'email': 'company2@example.com',
'password': 'SecurePass456!',
}
business.models.Company.objects.create_company(**cls.company2_data)
cls.company2 = business.models.Company.objects.get(
email=cls.company2_data['email'],
)
response1 = cls.client.post(
cls.company_signin_url,
{
'email': cls.company1_data['email'],
'password': cls.company1_data['password'],
},
format='json',
)
cls.company1_token = response1.data['access']
response2 = cls.client.post(
cls.company_signin_url,
{
'email': cls.company2_data['email'],
'password': cls.company2_data['password'],
},
format='json',
)
cls.company2_token = response2.data['access']
@classmethod
def promo_detail_url(cls, promo_id):
return django.urls.reverse(
'api-business:promo-detail',
kwargs={'id': promo_id},
)
def tearDown(self):
business.models.Company.objects.all().delete()
business.models.Promo.objects.all().delete()
business.models.PromoCode.objects.all().delete()
user.models.PromoActivationHistory.objects.all().delete()