-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathconftest.py
149 lines (121 loc) · 4.91 KB
/
conftest.py
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
from datetime import date, timedelta
from django.conf import settings
from django.contrib.auth import get_user_model
from django.test import Client
import pytest
from pytest_factoryboy import register
from authentication.tests.factories.student_user_factory import StudentUserFactory
from authentication.tests.factories.user_factory import UserFactory
from payment.tests.factories.referral_coupon_factory import ReferralCouponFactory
from payment.tests.factories.coupon_effect_factory import CouponEffectFactory
from staff.tests.factories.batch_factory import BatchFactory
from staff.tests.factories.batch_schedule_factory import BatchScheduleFactory
from staff.tests.factories.course_factory import CourseFactory
from staff.tests.factories.section_factory import SectionFactory
from student.tests.factories.certificate_factory import CertificateFactory
from student.tests.factories.enrolment_factory import EnrolmentFactory
from student.tests.factories.registration_factory import RegistrationFactory
register(BatchFactory)
register(BatchScheduleFactory)
register(CertificateFactory)
register(CouponEffectFactory)
register(CourseFactory)
register(EnrolmentFactory)
register(ReferralCouponFactory)
register(RegistrationFactory)
register(SectionFactory)
register(StudentUserFactory)
register(UserFactory)
client = Client
##################
# AUTHENTICATION #
##################
@pytest.fixture()
def existing_user():
User = get_user_model()
existing_user = User.objects.create_user(
email='user@domain.com',
first_name='FirstName',
last_name='LastName',
password=settings.PLACEHOLDER_PASSWORD
)
yield existing_user
#########
# BATCH #
#########
@pytest.fixture()
def coding_basics_batch(batch_factory, section_factory, batch_schedule_factory):
coding_basics_batch = batch_factory()
section_factory(batch=coding_basics_batch)
batch_schedule_factory(batch=coding_basics_batch)
yield coding_basics_batch
@pytest.fixture()
def coding_bootcamp_batch(batch_factory, course_factory, section_factory, batch_schedule_factory):
coding_bootcamp_batch = batch_factory(course=course_factory(coding_bootcamp=True))
coding_bootcamp_batch.price = 7999
section_factory(batch=coding_bootcamp_batch)
batch_schedule_factory(batch=coding_bootcamp_batch)
yield coding_bootcamp_batch
@pytest.fixture()
def swe_fundamentals_batch(batch_factory, course_factory, section_factory, batch_schedule_factory):
swe_fundamentals_batch = batch_factory(course=course_factory(swe_fundamentals=True))
section_factory(batch=swe_fundamentals_batch)
batch_schedule_factory(batch=swe_fundamentals_batch)
yield swe_fundamentals_batch
###################
# COUPON EFFECT #
###################
@pytest.fixture()
def swe_fundamentals_coupon_effect(coupon_effect_factory, course_factory):
swe_fundamentals_course = course_factory(swe_fundamentals=True)
swe_fundamentals_coupon_effect = coupon_effect_factory(
dollars_off=True,
discount_amount=20,
couponable_id=swe_fundamentals_course.id,
couponable_type=type(swe_fundamentals_course).__name__
)
yield swe_fundamentals_coupon_effect
@pytest.fixture()
def coding_bootcamp_coupon_effect(coupon_effect_factory, course_factory):
coding_bootcamp_course = course_factory(coding_bootcamp=True)
coding_bootcamp_coupon_effect = coupon_effect_factory(
dollars_off=True,
discount_amount=200,
couponable_id=coding_bootcamp_course.id,
couponable_type=type(coding_bootcamp_course).__name__
)
yield coding_bootcamp_coupon_effect
################
# REGISTRATION #
################
@pytest.fixture()
def coding_basics_registration(coding_basics_batch, registration_factory):
coding_basics_registration = registration_factory(
batch=coding_basics_batch,
course=coding_basics_batch.course
)
yield coding_basics_registration
@pytest.fixture()
def coding_bootcamp_registration(coding_bootcamp_batch, registration_factory):
coding_bootcamp_registration = registration_factory(
batch=coding_bootcamp_batch,
course=coding_bootcamp_batch.course
)
yield coding_bootcamp_registration
@pytest.fixture()
def swe_fundamentals_registration(swe_fundamentals_batch, registration_factory):
swe_fundamentals_registration = registration_factory(
batch=swe_fundamentals_batch,
course=swe_fundamentals_batch.course
)
yield swe_fundamentals_registration
@pytest.fixture()
def swe_fundamentals_registration_early_bird(swe_fundamentals_batch, registration_factory):
swe_fundamentals_batch.start_date = date.today() + timedelta(days=21)
swe_fundamentals_batch.end_date = date.today() + timedelta(days=22)
swe_fundamentals_batch.save()
swe_fundamentals_registration_early_bird = registration_factory(
batch=swe_fundamentals_batch,
course=swe_fundamentals_batch.course,
)
yield swe_fundamentals_registration_early_bird