@@ -144,7 +144,7 @@ def test_create_motor_optional_params(stub_motor):
144
144
mock_create_motor .assert_called_once_with (Motor (** stub_motor ))
145
145
146
146
147
- def create_generic_motor (stub_motor ):
147
+ def test_create_generic_motor (stub_motor ):
148
148
stub_motor .update (
149
149
{
150
150
'chamber_radius' : 0 ,
@@ -174,7 +174,7 @@ def create_generic_motor(stub_motor):
174
174
mock_create_motor .assert_called_once_with (Motor (** stub_motor ))
175
175
176
176
177
- def create_liquid_motor_level_tank (stub_motor , stub_level_tank ):
177
+ def test_create_liquid_motor_level_tank (stub_motor , stub_level_tank ):
178
178
stub_motor .update ({'tanks' : [stub_level_tank ]})
179
179
with patch .object (
180
180
MotorController ,
@@ -196,6 +196,72 @@ def create_liquid_motor_level_tank(stub_motor, stub_level_tank):
196
196
mock_create_motor .assert_called_once_with (Motor (** stub_motor ))
197
197
198
198
199
+ def test_create_liquid_motor_mass_flow_tank (stub_motor , stub_mass_flow_tank ):
200
+ stub_motor .update ({'tanks' : [stub_mass_flow_tank ]})
201
+ with patch .object (
202
+ MotorController ,
203
+ 'create_motor' ,
204
+ return_value = MotorCreated (motor_id = '123' ),
205
+ ) as mock_create_motor :
206
+ with patch .object (
207
+ Motor , 'set_motor_kind' , side_effect = None
208
+ ) as mock_set_motor_kind :
209
+ response = client .post (
210
+ '/motors/' , json = stub_motor , params = {'motor_kind' : 'LIQUID' }
211
+ )
212
+ assert response .status_code == 200
213
+ assert response .json () == {
214
+ 'motor_id' : '123' ,
215
+ 'message' : 'Motor successfully created' ,
216
+ }
217
+ mock_set_motor_kind .assert_called_once_with (MotorKinds .LIQUID )
218
+ mock_create_motor .assert_called_once_with (Motor (** stub_motor ))
219
+
220
+
221
+ def test_create_liquid_motor_ullage_tank (stub_motor , stub_ullage_tank ):
222
+ stub_motor .update ({'tanks' : [stub_ullage_tank ]})
223
+ with patch .object (
224
+ MotorController ,
225
+ 'create_motor' ,
226
+ return_value = MotorCreated (motor_id = '123' ),
227
+ ) as mock_create_motor :
228
+ with patch .object (
229
+ Motor , 'set_motor_kind' , side_effect = None
230
+ ) as mock_set_motor_kind :
231
+ response = client .post (
232
+ '/motors/' , json = stub_motor , params = {'motor_kind' : 'LIQUID' }
233
+ )
234
+ assert response .status_code == 200
235
+ assert response .json () == {
236
+ 'motor_id' : '123' ,
237
+ 'message' : 'Motor successfully created' ,
238
+ }
239
+ mock_set_motor_kind .assert_called_once_with (MotorKinds .LIQUID )
240
+ mock_create_motor .assert_called_once_with (Motor (** stub_motor ))
241
+
242
+
243
+ def test_create_liquid_motor_mass_tank (stub_motor , stub_mass_tank ):
244
+ stub_motor .update ({'tanks' : [stub_mass_tank ]})
245
+ with patch .object (
246
+ MotorController ,
247
+ 'create_motor' ,
248
+ return_value = MotorCreated (motor_id = '123' ),
249
+ ) as mock_create_motor :
250
+ with patch .object (
251
+ Motor , 'set_motor_kind' , side_effect = None
252
+ ) as mock_set_motor_kind :
253
+ response = client .post (
254
+ '/motors/' , json = stub_motor , params = {'motor_kind' : 'LIQUID' }
255
+ )
256
+ assert response .status_code == 200
257
+ assert response .json () == {
258
+ 'motor_id' : '123' ,
259
+ 'message' : 'Motor successfully created' ,
260
+ }
261
+ mock_set_motor_kind .assert_called_once_with (MotorKinds .LIQUID )
262
+ mock_create_motor .assert_called_once_with (Motor (** stub_motor ))
263
+
264
+
199
265
def test_create_hybrid_motor (stub_motor , stub_level_tank ):
200
266
stub_motor .update (
201
267
{
0 commit comments