Coverage for tests/test_mobius_adapter.py: 100%

6 statements  

« prev     ^ index     » next       coverage.py v7.0.0, created at 2022-12-20 14:31 +0000

1from datetime import datetime 

2 

3from mobius_adapter.utils import Reading, to_mobius_payload 

4 

5 

6def test_to_mobius_payload(reading: Reading): 

7 """ 

8 Coherence test for to_mobius_payload() function 

9 """ 

10 sensorId: str = "foo_bar_Id" 

11 

12 expected_value = { 

13 "m2m:cin": { 

14 "con": { 

15 "metadata": { 

16 "sensorId": sensorId, 

17 "readingTimestamp": datetime.fromtimestamp( 

18 reading.readingID 

19 ).isoformat(), 

20 } 

21 }, 

22 "sensorData": { 

23 "canID": reading.canID, 

24 "sensorNumber": reading.sensorNumber, 

25 "dangerLevel": reading.dangerLevel, 

26 "window1Count": reading.window1, 

27 "window2Count": reading.window2, 

28 "window3Count": reading.window3, 

29 }, 

30 } 

31 } 

32 

33 assert ( 

34 to_mobius_payload(reading, sensorId) == expected_value 

35 ), "Error in `to_mobius_payload`: output mismatch"