Skip to content

Commit

Permalink
Update test_purpleair_data_logger_helpers.py
Browse files Browse the repository at this point in the history
- added test_construct_store_sensor_data_type
  • Loading branch information
carlkidcrypto committed Nov 12, 2023
1 parent 3afd9fc commit e223333
Showing 1 changed file with 377 additions and 2 deletions.
379 changes: 377 additions & 2 deletions tests/test_purpleair_data_logger_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,385 @@ def test_validate_sensor_data_before_insert(self):
}
self.assertEqual(validate_sensor_data_before_insert({}), expected_value)


def test_construct_store_sensor_data_type(self):
"""
Test that our contructor makes the dict data type that the PurpleAirDataLogger.store_sensor_data method expects.
"""

#construct_store_sensor_data_type()
# The sensors data will look something like this:
# {'api_version': 'V1.0.11-0.0.34', 'time_stamp': 1659710288, 'data_time_stamp': 1659710232,
# 'max_age': 604800, 'firmware_default_version': '7.00', 'fields': ['sensor_index', 'name'],
# 'data': [[131075, 'Mariners Bluff'], [131079, 'BRSKBV-outside'], [131077, 'BEE Patio'],
# ... ]}

data_in = {
"api_version": "V1.0.11-0.0.34",
"time_stamp": 1659710288,
"data_time_stamp": 1659710232,
"max_age": 604800,
"firmware_default_version": "7.00",
"fields": ["sensor_index", "name"],
"data": [[1, "TEST1"], [2, "TEST2"], [3, "TEST3"]],
}

data_out = [
{
"data_time_stamp": 1659710232,
"sensor_index": 1,
"name": "TEST1",
"icon": 0,
"model": "",
"hardware": "",
"location_type": 0,
"private": 0,
"latitude": 0.0,
"longitude": 0.0,
"altitude": 0.0,
"position_rating": 0,
"led_brightness": 0,
"firmware_version": "",
"firmware_upgrade": "",
"rssi": 0,
"uptime": 0,
"pa_latency": 0,
"memory": 0,
"last_seen": 0,
"last_modified": 0,
"date_created": 0,
"channel_state": 0,
"channel_flags": 0,
"channel_flags_manual": 0,
"channel_flags_auto": 0,
"confidence": 0,
"confidence_manual": 0,
"confidence_auto": 0,
"humidity": 0,
"humidity_a": 0,
"humidity_b": 0,
"temperature": 0,
"temperature_a": 0,
"temperature_b": 0,
"pressure": 0.0,
"pressure_a": 0.0,
"pressure_b": 0.0,
"voc": 0.0,
"voc_a": 0.0,
"voc_b": 0.0,
"ozone1": 0.0,
"analog_input": 0.0,
"pm1.0": 0.0,
"pm1.0_a": 0.0,
"pm1.0_b": 0.0,
"pm1.0_atm": 0.0,
"pm1.0_atm_a": 0.0,
"pm1.0_atm_b": 0.0,
"pm1.0_cf_1": 0.0,
"pm1.0_cf_1_a": 0.0,
"pm1.0_cf_1_b": 0.0,
"pm2.5_alt": 0.0,
"pm2.5_alt_a": 0.0,
"pm2.5_alt_b": 0.0,
"pm2.5": 0.0,
"pm2.5_a": 0.0,
"pm2.5_b": 0.0,
"pm2.5_atm": 0.0,
"pm2.5_atm_a": 0.0,
"pm2.5_atm_b": 0.0,
"pm2.5_cf_1": 0.0,
"pm2.5_cf_1_a": 0.0,
"pm2.5_cf_1_b": 0.0,
"pm2.5_10minute": 0.0,
"pm2.5_10minute_a": 0.0,
"pm2.5_10minute_b": 0.0,
"pm2.5_30minute": 0.0,
"pm2.5_30minute_a": 0.0,
"pm2.5_30minute_b": 0.0,
"pm2.5_60minute": 0.0,
"pm2.5_60minute_a": 0.0,
"pm2.5_60minute_b": 0.0,
"pm2.5_6hour": 0.0,
"pm2.5_6hour_a": 0.0,
"pm2.5_6hour_b": 0.0,
"pm2.5_24hour": 0.0,
"pm2.5_24hour_a": 0.0,
"pm2.5_24hour_b": 0.0,
"pm2.5_1week": 0.0,
"pm2.5_1week_a": 0.0,
"pm2.5_1week_b": 0.0,
"pm10.0": 0.0,
"pm10.0_a": 0.0,
"pm10.0_b": 0.0,
"pm10.0_atm": 0.0,
"pm10.0_atm_a": 0.0,
"pm10.0_atm_b": 0.0,
"pm10.0_cf_1": 0.0,
"pm10.0_cf_1_a": 0.0,
"pm10.0_cf_1_b": 0.0,
"0.3_um_count": 0.0,
"0.3_um_count_a": 0.0,
"0.3_um_count_b": 0.0,
"0.5_um_count": 0.0,
"0.5_um_count_a": 0.0,
"0.5_um_count_b": 0.0,
"1.0_um_count": 0.0,
"1.0_um_count_a": 0.0,
"1.0_um_count_b": 0.0,
"2.5_um_count": 0.0,
"2.5_um_count_a": 0.0,
"2.5_um_count_b": 0.0,
"5.0_um_count": 0.0,
"5.0_um_count_a": 0.0,
"5.0_um_count_b": 0.0,
"10.0_um_count": 0.0,
"10.0_um_count_a": 0.0,
"10.0_um_count_b": 0.0,
"primary_id_a": 0,
"primary_key_a": "",
"secondary_id_a": 0,
"secondary_key_a": "",
"primary_id_b": 0,
"primary_key_b": "",
"secondary_id_b": 0,
"secondary_key_b": "",
},
{
"data_time_stamp": 1659710232,
"sensor_index": 2,
"name": "TEST2",
"icon": 0,
"model": "",
"hardware": "",
"location_type": 0,
"private": 0,
"latitude": 0.0,
"longitude": 0.0,
"altitude": 0.0,
"position_rating": 0,
"led_brightness": 0,
"firmware_version": "",
"firmware_upgrade": "",
"rssi": 0,
"uptime": 0,
"pa_latency": 0,
"memory": 0,
"last_seen": 0,
"last_modified": 0,
"date_created": 0,
"channel_state": 0,
"channel_flags": 0,
"channel_flags_manual": 0,
"channel_flags_auto": 0,
"confidence": 0,
"confidence_manual": 0,
"confidence_auto": 0,
"humidity": 0,
"humidity_a": 0,
"humidity_b": 0,
"temperature": 0,
"temperature_a": 0,
"temperature_b": 0,
"pressure": 0.0,
"pressure_a": 0.0,
"pressure_b": 0.0,
"voc": 0.0,
"voc_a": 0.0,
"voc_b": 0.0,
"ozone1": 0.0,
"analog_input": 0.0,
"pm1.0": 0.0,
"pm1.0_a": 0.0,
"pm1.0_b": 0.0,
"pm1.0_atm": 0.0,
"pm1.0_atm_a": 0.0,
"pm1.0_atm_b": 0.0,
"pm1.0_cf_1": 0.0,
"pm1.0_cf_1_a": 0.0,
"pm1.0_cf_1_b": 0.0,
"pm2.5_alt": 0.0,
"pm2.5_alt_a": 0.0,
"pm2.5_alt_b": 0.0,
"pm2.5": 0.0,
"pm2.5_a": 0.0,
"pm2.5_b": 0.0,
"pm2.5_atm": 0.0,
"pm2.5_atm_a": 0.0,
"pm2.5_atm_b": 0.0,
"pm2.5_cf_1": 0.0,
"pm2.5_cf_1_a": 0.0,
"pm2.5_cf_1_b": 0.0,
"pm2.5_10minute": 0.0,
"pm2.5_10minute_a": 0.0,
"pm2.5_10minute_b": 0.0,
"pm2.5_30minute": 0.0,
"pm2.5_30minute_a": 0.0,
"pm2.5_30minute_b": 0.0,
"pm2.5_60minute": 0.0,
"pm2.5_60minute_a": 0.0,
"pm2.5_60minute_b": 0.0,
"pm2.5_6hour": 0.0,
"pm2.5_6hour_a": 0.0,
"pm2.5_6hour_b": 0.0,
"pm2.5_24hour": 0.0,
"pm2.5_24hour_a": 0.0,
"pm2.5_24hour_b": 0.0,
"pm2.5_1week": 0.0,
"pm2.5_1week_a": 0.0,
"pm2.5_1week_b": 0.0,
"pm10.0": 0.0,
"pm10.0_a": 0.0,
"pm10.0_b": 0.0,
"pm10.0_atm": 0.0,
"pm10.0_atm_a": 0.0,
"pm10.0_atm_b": 0.0,
"pm10.0_cf_1": 0.0,
"pm10.0_cf_1_a": 0.0,
"pm10.0_cf_1_b": 0.0,
"0.3_um_count": 0.0,
"0.3_um_count_a": 0.0,
"0.3_um_count_b": 0.0,
"0.5_um_count": 0.0,
"0.5_um_count_a": 0.0,
"0.5_um_count_b": 0.0,
"1.0_um_count": 0.0,
"1.0_um_count_a": 0.0,
"1.0_um_count_b": 0.0,
"2.5_um_count": 0.0,
"2.5_um_count_a": 0.0,
"2.5_um_count_b": 0.0,
"5.0_um_count": 0.0,
"5.0_um_count_a": 0.0,
"5.0_um_count_b": 0.0,
"10.0_um_count": 0.0,
"10.0_um_count_a": 0.0,
"10.0_um_count_b": 0.0,
"primary_id_a": 0,
"primary_key_a": "",
"secondary_id_a": 0,
"secondary_key_a": "",
"primary_id_b": 0,
"primary_key_b": "",
"secondary_id_b": 0,
"secondary_key_b": "",
},
{
"data_time_stamp": 1659710232,
"sensor_index": 3,
"name": "TEST3",
"icon": 0,
"model": "",
"hardware": "",
"location_type": 0,
"private": 0,
"latitude": 0.0,
"longitude": 0.0,
"altitude": 0.0,
"position_rating": 0,
"led_brightness": 0,
"firmware_version": "",
"firmware_upgrade": "",
"rssi": 0,
"uptime": 0,
"pa_latency": 0,
"memory": 0,
"last_seen": 0,
"last_modified": 0,
"date_created": 0,
"channel_state": 0,
"channel_flags": 0,
"channel_flags_manual": 0,
"channel_flags_auto": 0,
"confidence": 0,
"confidence_manual": 0,
"confidence_auto": 0,
"humidity": 0,
"humidity_a": 0,
"humidity_b": 0,
"temperature": 0,
"temperature_a": 0,
"temperature_b": 0,
"pressure": 0.0,
"pressure_a": 0.0,
"pressure_b": 0.0,
"voc": 0.0,
"voc_a": 0.0,
"voc_b": 0.0,
"ozone1": 0.0,
"analog_input": 0.0,
"pm1.0": 0.0,
"pm1.0_a": 0.0,
"pm1.0_b": 0.0,
"pm1.0_atm": 0.0,
"pm1.0_atm_a": 0.0,
"pm1.0_atm_b": 0.0,
"pm1.0_cf_1": 0.0,
"pm1.0_cf_1_a": 0.0,
"pm1.0_cf_1_b": 0.0,
"pm2.5_alt": 0.0,
"pm2.5_alt_a": 0.0,
"pm2.5_alt_b": 0.0,
"pm2.5": 0.0,
"pm2.5_a": 0.0,
"pm2.5_b": 0.0,
"pm2.5_atm": 0.0,
"pm2.5_atm_a": 0.0,
"pm2.5_atm_b": 0.0,
"pm2.5_cf_1": 0.0,
"pm2.5_cf_1_a": 0.0,
"pm2.5_cf_1_b": 0.0,
"pm2.5_10minute": 0.0,
"pm2.5_10minute_a": 0.0,
"pm2.5_10minute_b": 0.0,
"pm2.5_30minute": 0.0,
"pm2.5_30minute_a": 0.0,
"pm2.5_30minute_b": 0.0,
"pm2.5_60minute": 0.0,
"pm2.5_60minute_a": 0.0,
"pm2.5_60minute_b": 0.0,
"pm2.5_6hour": 0.0,
"pm2.5_6hour_a": 0.0,
"pm2.5_6hour_b": 0.0,
"pm2.5_24hour": 0.0,
"pm2.5_24hour_a": 0.0,
"pm2.5_24hour_b": 0.0,
"pm2.5_1week": 0.0,
"pm2.5_1week_a": 0.0,
"pm2.5_1week_b": 0.0,
"pm10.0": 0.0,
"pm10.0_a": 0.0,
"pm10.0_b": 0.0,
"pm10.0_atm": 0.0,
"pm10.0_atm_a": 0.0,
"pm10.0_atm_b": 0.0,
"pm10.0_cf_1": 0.0,
"pm10.0_cf_1_a": 0.0,
"pm10.0_cf_1_b": 0.0,
"0.3_um_count": 0.0,
"0.3_um_count_a": 0.0,
"0.3_um_count_b": 0.0,
"0.5_um_count": 0.0,
"0.5_um_count_a": 0.0,
"0.5_um_count_b": 0.0,
"1.0_um_count": 0.0,
"1.0_um_count_a": 0.0,
"1.0_um_count_b": 0.0,
"2.5_um_count": 0.0,
"2.5_um_count_a": 0.0,
"2.5_um_count_b": 0.0,
"5.0_um_count": 0.0,
"5.0_um_count_a": 0.0,
"5.0_um_count_b": 0.0,
"10.0_um_count": 0.0,
"10.0_um_count_a": 0.0,
"10.0_um_count_b": 0.0,
"primary_id_a": 0,
"primary_key_a": "",
"secondary_id_a": 0,
"secondary_key_a": "",
"primary_id_b": 0,
"primary_key_b": "",
"secondary_id_b": 0,
"secondary_key_b": "",
},
]
retval = construct_store_sensor_data_type(data_in)
self.assertEqual(retval, data_out)

0 comments on commit e223333

Please sign in to comment.