1
1
"""Tests for robot_server.modules.module_data_mapper."""
2
2
import pytest
3
+ from typing import Dict
3
4
4
5
from opentrons .protocol_engine import ModuleModel , DeckType
5
6
from opentrons .protocol_engine .types import Vec3f
10
11
MagneticStatus ,
11
12
TemperatureStatus ,
12
13
HeaterShakerStatus ,
14
+ types as hc_types ,
13
15
)
14
16
15
17
@@ -174,22 +176,21 @@ def test_maps_magnetic_module_data(
174
176
],
175
177
)
176
178
@pytest .mark .parametrize (
177
- "input_data " ,
179
+ "status,data " ,
178
180
[
179
- {"status" : "idle" , "data" : {"currentTemp" : 42.0 , "targetTemp" : None }},
180
- {
181
- "status" : "holding at target" ,
182
- "data" : {"currentTemp" : 84.0 , "targetTemp" : 84.0 },
183
- },
181
+ ("idle" , {"currentTemp" : 42.0 , "targetTemp" : None }),
182
+ ("holding at target" , {"currentTemp" : 84.0 , "targetTemp" : 84.0 }),
184
183
],
185
184
)
186
185
def test_maps_temperature_module_data (
187
186
input_model : str ,
188
187
deck_type : DeckType ,
189
188
expected_compatible : bool ,
190
- input_data : LiveData ,
189
+ status : str ,
190
+ data : hc_types .TemperatureModuleData ,
191
191
) -> None :
192
192
"""It should map hardware data to a magnetic module."""
193
+ input_data : LiveData = {"status" : status , "data" : data }
193
194
module_identity = ModuleIdentity (
194
195
module_id = "module-id" ,
195
196
serial_number = "serial-number" ,
@@ -236,9 +237,9 @@ def test_maps_temperature_module_data(
236
237
),
237
238
moduleOffset = ModuleCalibrationData (offset = Vec3f (x = 0.0 , y = 0.0 , z = 0.0 )),
238
239
data = TemperatureModuleData (
239
- status = TemperatureStatus (input_data [ " status" ] ),
240
- currentTemperature = input_data [ " data" ] ["currentTemp" ], # type: ignore[arg-type]
241
- targetTemperature = input_data [ " data" ] ["targetTemp" ], # type: ignore[arg-type]
240
+ status = TemperatureStatus (status ),
241
+ currentTemperature = data ["currentTemp" ],
242
+ targetTemperature = data ["targetTemp" ],
242
243
),
243
244
)
244
245
@@ -253,11 +254,11 @@ def test_maps_temperature_module_data(
253
254
],
254
255
)
255
256
@pytest .mark .parametrize (
256
- "input_data " ,
257
+ "status,data " ,
257
258
[
258
- {
259
- "status" : " idle" ,
260
- "data" : {
259
+ (
260
+ "idle" ,
261
+ {
261
262
"lid" : "open" ,
262
263
"lidTarget" : None ,
263
264
"lidTemp" : None ,
@@ -271,10 +272,10 @@ def test_maps_temperature_module_data(
271
272
"currentStepIndex" : None ,
272
273
"totalStepCount" : None ,
273
274
},
274
- } ,
275
- {
276
- "status" : " heating" ,
277
- "data" : {
275
+ ) ,
276
+ (
277
+ "heating" ,
278
+ {
278
279
"lid" : "open" ,
279
280
"lidTarget" : 1 ,
280
281
"lidTemp" : 2 ,
@@ -288,16 +289,18 @@ def test_maps_temperature_module_data(
288
289
"currentStepIndex" : 9 ,
289
290
"totalStepCount" : 10 ,
290
291
},
291
- } ,
292
+ ) ,
292
293
],
293
294
)
294
295
def test_maps_thermocycler_module_data (
295
296
input_model : str ,
296
297
deck_type : DeckType ,
297
298
expected_compatible : bool ,
298
- input_data : LiveData ,
299
+ status : str ,
300
+ data : hc_types .ThermocyclerData ,
299
301
) -> None :
300
302
"""It should map hardware data to a magnetic module."""
303
+ input_data : LiveData = {"status" : status , "data" : data }
301
304
module_identity = ModuleIdentity (
302
305
module_id = "module-id" ,
303
306
serial_number = "serial-number" ,
@@ -344,19 +347,19 @@ def test_maps_thermocycler_module_data(
344
347
),
345
348
moduleOffset = ModuleCalibrationData (offset = Vec3f (x = 0.0 , y = 0.0 , z = 0.0 )),
346
349
data = ThermocyclerModuleData (
347
- status = TemperatureStatus (input_data [ " status" ] ),
348
- currentTemperature = input_data [ " data" ] ["currentTemp" ], # type: ignore[arg-type]
349
- targetTemperature = input_data [ " data" ] ["targetTemp" ], # type: ignore[arg-type]
350
- lidStatus = input_data [ " data" ] ["lid" ], # type: ignore[arg-type]
351
- lidTemperatureStatus = input_data [ " data" ] ["lidTempStatus" ], # type: ignore[arg-type]
352
- lidTemperature = input_data [ " data" ] ["lidTemp" ], # type: ignore[arg-type]
353
- lidTargetTemperature = input_data [ " data" ] ["lidTarget" ], # type: ignore[arg-type]
354
- holdTime = input_data [ " data" ] ["holdTime" ], # type: ignore[arg-type]
355
- rampRate = input_data [ " data" ] ["rampRate" ], # type: ignore[arg-type]
356
- currentCycleIndex = input_data [ " data" ] ["currentCycleIndex" ], # type: ignore[arg-type]
357
- totalCycleCount = input_data [ " data" ] ["totalCycleCount" ], # type: ignore[arg-type]
358
- currentStepIndex = input_data [ " data" ] ["currentStepIndex" ], # type: ignore[arg-type]
359
- totalStepCount = input_data [ " data" ] ["totalStepCount" ], # type: ignore[arg-type]
350
+ status = TemperatureStatus (status ),
351
+ currentTemperature = data ["currentTemp" ],
352
+ targetTemperature = data ["targetTemp" ],
353
+ lidStatus = data ["lid" ], # type: ignore[arg-type]
354
+ lidTemperatureStatus = data ["lidTempStatus" ], # type: ignore[arg-type]
355
+ lidTemperature = data ["lidTemp" ],
356
+ lidTargetTemperature = data ["lidTarget" ],
357
+ holdTime = data ["holdTime" ],
358
+ rampRate = data ["rampRate" ],
359
+ currentCycleIndex = data ["currentCycleIndex" ],
360
+ totalCycleCount = data ["totalCycleCount" ],
361
+ currentStepIndex = data ["currentStepIndex" ],
362
+ totalStepCount = data ["totalStepCount" ],
360
363
),
361
364
)
362
365
@@ -369,11 +372,11 @@ def test_maps_thermocycler_module_data(
369
372
],
370
373
)
371
374
@pytest .mark .parametrize (
372
- "input_data " ,
375
+ "status,data " ,
373
376
[
374
- {
375
- "status" : " idle" ,
376
- "data" : {
377
+ (
378
+ "idle" ,
379
+ {
377
380
"temperatureStatus" : "idle" ,
378
381
"speedStatus" : "idle" ,
379
382
"labwareLatchStatus" : "idle_open" ,
@@ -383,10 +386,10 @@ def test_maps_thermocycler_module_data(
383
386
"targetSpeed" : None ,
384
387
"errorDetails" : None ,
385
388
},
386
- } ,
387
- {
388
- "status" : " running" ,
389
- "data" : {
389
+ ) ,
390
+ (
391
+ "running" ,
392
+ {
390
393
"temperatureStatus" : "heating" ,
391
394
"speedStatus" : "speeding up" ,
392
395
"labwareLatchStatus" : "idle_closed" ,
@@ -396,13 +399,14 @@ def test_maps_thermocycler_module_data(
396
399
"targetSpeed" : 9001 ,
397
400
"errorDetails" : "oh no" ,
398
401
},
399
- } ,
402
+ ) ,
400
403
],
401
404
)
402
405
def test_maps_heater_shaker_module_data (
403
- input_model : str , deck_type : DeckType , input_data : LiveData
406
+ input_model : str , deck_type : DeckType , status : str , data : hc_types . HeaterShakerData
404
407
) -> None :
405
408
"""It should map hardware data to a magnetic module."""
409
+ input_data : LiveData = {"status" : status , "data" : data }
406
410
module_identity = ModuleIdentity (
407
411
module_id = "module-id" ,
408
412
serial_number = "serial-number" ,
@@ -449,14 +453,14 @@ def test_maps_heater_shaker_module_data(
449
453
),
450
454
moduleOffset = ModuleCalibrationData (offset = Vec3f (x = 0.0 , y = 0.0 , z = 0.0 )),
451
455
data = HeaterShakerModuleData (
452
- status = HeaterShakerStatus (input_data [ " status" ] ),
453
- labwareLatchStatus = input_data [ " data" ] ["labwareLatchStatus" ], # type: ignore[arg-type]
454
- speedStatus = input_data [ " data" ] ["speedStatus" ], # type: ignore[arg-type]
455
- currentSpeed = input_data [ " data" ] ["currentSpeed" ], # type: ignore[arg-type]
456
- targetSpeed = input_data [ " data" ] ["targetSpeed" ], # type: ignore[arg-type]
457
- temperatureStatus = input_data [ " data" ] ["temperatureStatus" ], # type: ignore[arg-type]
458
- currentTemperature = input_data [ " data" ] ["currentTemp" ], # type: ignore[arg-type]
459
- targetTemperature = input_data [ " data" ] ["targetTemp" ], # type: ignore[arg-type]
460
- errorDetails = input_data [ " data" ] ["errorDetails" ], # type: ignore[arg-type]
456
+ status = HeaterShakerStatus (status ),
457
+ labwareLatchStatus = data ["labwareLatchStatus" ], # type: ignore[arg-type]
458
+ speedStatus = data ["speedStatus" ], # type: ignore[arg-type]
459
+ currentSpeed = data ["currentSpeed" ],
460
+ targetSpeed = data ["targetSpeed" ],
461
+ temperatureStatus = data ["temperatureStatus" ], # type: ignore[arg-type]
462
+ currentTemperature = data ["currentTemp" ],
463
+ targetTemperature = data ["targetTemp" ],
464
+ errorDetails = data ["errorDetails" ],
461
465
),
462
466
)
0 commit comments