@@ -80,51 +80,6 @@ def test_user():
80
80
assert icloud_account .user .name == "Archibald Tuttle"
81
81
82
82
83
- def test_project ():
84
- project = model .Project (
85
- title = "Heating Repair" ,
86
- tag = "#heating-repair" ,
87
- start_date = datetime .date .today (),
88
- end_date = datetime .date .today () + datetime .timedelta (days = 80 ),
89
- )
90
- assert store_and_retrieve (project )
91
-
92
-
93
- def test_contract ():
94
-
95
- the_client = model .Client (
96
- name = "Central Services" ,
97
- invoicing_contact = model .Contact (
98
- first_name = "Central" ,
99
- last_name = "Services" ,
100
- company = "Central Services" ,
101
- address = model .Address (
102
- street = "Down the Road" ,
103
- number = "55" ,
104
- city = "Somewhere" ,
105
- postal_code = "99999" ,
106
- country = "Brazil" ,
107
- ),
108
-
109
- ),
110
- )
111
-
112
- the_contract = model .Contract (
113
- title = "CS Q1 2022" ,
114
- client = the_client ,
115
- start_date = datetime .date (2022 , 1 , 1 ),
116
- end_date = datetime .date (2022 , 3 , 31 ),
117
- signature_date = datetime .date (2021 , 10 , 31 ),
118
- rate = 100 ,
119
- unit = time .TimeUnit .hour ,
120
- currency = "EUR" ,
121
- billing_cycle = time .Cycle .monthly ,
122
- volume = 3 * 8 * 8 ,
123
- units_per_workday = 8 ,
124
- )
125
- assert store_and_retrieve (the_contract )
126
-
127
-
128
83
class TestContact :
129
84
def test_valid_contact_instantiation (self ):
130
85
contact = Contact (
@@ -148,24 +103,61 @@ def test_invalid_email_instantiation(self):
148
103
149
104
150
105
class TestClient :
106
+ """Tests for the Client model."""
107
+
151
108
def test_valid_instantiation (self ):
152
109
invoicing_contact = Contact (
153
110
first_name = "Sam" ,
154
111
last_name = "Lowry" ,
155
112
156
113
company = "Ministry of Information" ,
157
114
)
158
- client = Client (
159
- name = "Ministry of Information" , invoicing_contact = invoicing_contact
115
+ client = Client .validate (
116
+ dict (
117
+ name = "Ministry of Information" ,
118
+ invoicing_contact = invoicing_contact ,
119
+ )
160
120
)
161
121
assert store_and_retrieve (client )
162
122
163
123
def test_missing_fields_instantiation (self ):
164
124
with pytest .raises (ValidationError ):
165
- Client () # type: ignore
125
+ Client . validate ( dict ())
166
126
167
127
168
128
class TestContract :
129
+ """Tests for the Contract model."""
130
+
131
+ def test_valid_instantiation (self ):
132
+ client = Client (name = "Ministry of Information" )
133
+ contract = Contract .validate (
134
+ dict (
135
+ title = "Project X Contract" ,
136
+ client = client ,
137
+ signature_date = datetime .date (2022 , 10 , 1 ),
138
+ start_date = datetime .date (2022 , 10 , 2 ),
139
+ end_date = datetime .date (2022 , 12 , 31 ),
140
+ rate = 100 ,
141
+ is_completed = False ,
142
+ currency = "USD" ,
143
+ VAT_rate = 0.19 ,
144
+ unit = TimeUnit .hour ,
145
+ units_per_workday = 8 ,
146
+ volume = 100 ,
147
+ term_of_payment = 31 ,
148
+ billing_cycle = Cycle .monthly ,
149
+ )
150
+ )
151
+ assert store_and_retrieve (contract )
152
+
153
+ def test_missing_fields_instantiation (self ):
154
+ with pytest .raises (ValidationError ):
155
+ Contract .validate (dict ())
156
+
157
+
158
+ class TestProject :
159
+ """Tests for the Project model."""
160
+
169
161
def test_valid_instantiation (self ):
170
162
client = Client (name = "Ministry of Information" )
171
163
contract = Contract (
@@ -184,8 +176,30 @@ def test_valid_instantiation(self):
184
176
term_of_payment = 31 ,
185
177
billing_cycle = Cycle .monthly ,
186
178
)
187
- assert store_and_retrieve (contract )
179
+ project = Project .validate (
180
+ dict (
181
+ title = "Project X" ,
182
+ description = "The description of Project X" ,
183
+ tag = "#project_x" ,
184
+ start_date = datetime .date (2022 , 10 , 2 ),
185
+ end_date = datetime .date (2022 , 12 , 31 ),
186
+ contract = contract ,
187
+ )
188
+ )
189
+ assert store_and_retrieve (project )
188
190
189
191
def test_missing_fields_instantiation (self ):
190
192
with pytest .raises (ValidationError ):
191
- Contract () # type: ignore
193
+ Project .validate (dict ())
194
+
195
+ def test_invalid_tag_instantiation (self ):
196
+ with pytest .raises (ValidationError ):
197
+ Project .validate (
198
+ dict (
199
+ title = "Project X" ,
200
+ description = "The description of Project X" ,
201
+ tag = "project_x" ,
202
+ start_date = datetime .date (2022 , 10 , 2 ),
203
+ end_date = datetime .date (2022 , 12 , 31 ),
204
+ )
205
+ )
0 commit comments