From 502c1c36e257ae3cdbc59ec88a8c873e42bb6263 Mon Sep 17 00:00:00 2001 From: Weiyu Date: Tue, 6 Apr 2021 17:30:05 -0400 Subject: [PATCH] documented phone_battery_test and added event tests --- data/external/timesegments_event.csv | 13 +- data/external/timesegments_periodic.csv | 5 +- docs/developers/testing.md | 211 +++++++++++++++++- docs/stylesheets/extra.css | 3 +- .../external/aware_csv/phone_battery_raw.csv | 29 ++- .../external/participant_files/test07.yaml | 6 + .../features/event/test07/phone_battery.csv | 4 + .../periodic/test01/phone_battery.csv | 26 ++- tests/scripts/run_tests.py | 10 + tests/scripts/run_tests.sh | 7 +- tests/settings/event_config.yaml | 2 +- 11 files changed, 302 insertions(+), 14 deletions(-) create mode 100644 tests/data/external/participant_files/test07.yaml create mode 100644 tests/data/processed/features/event/test07/phone_battery.csv diff --git a/data/external/timesegments_event.csv b/data/external/timesegments_event.csv index 7d54b602..3d7c66e5 100644 --- a/data/external/timesegments_event.csv +++ b/data/external/timesegments_event.csv @@ -3,7 +3,12 @@ stress,1587661220000,1H,0M,1,a748ee1a-1d0b-4ae9-9074-279a2b6ba524 stress,1587747620000,4H,4H,-1,a748ee1a-1d0b-4ae9-9074-279a2b6ba524 stress,1587906020000,3H,0M,1,a748ee1a-1d0b-4ae9-9074-279a2b6ba524 stress,1588003220000,7H,4H,-1,a748ee1a-1d0b-4ae9-9074-279a2b6ba524 -stress,1588172420000,9H,0M,-1,a748ee1a-1d0b-4ae9-9074-279a2b6ba524 -mood,1587661220000,1H,0M,0,a748ee1a-1d0b-4ae9-9074-279a2b6ba524 -mood,1587747620000,1D,0M,0,a748ee1a-1d0b-4ae9-9074-279a2b6ba524 -mood,1587906020000,7D,0M,0,a748ee1a-1d0b-4ae9-9074-279a2b6ba524 + +stress,1588172420000,9H,0H,-1,a748ee1a-1d0b-4ae9-9074-279a2b6ba524 +mood,1587661220000,1H,0H,0,a748ee1a-1d0b-4ae9-9074-279a2b6ba524 +mood,1587747620000,1D,0H,0,a748ee1a-1d0b-4ae9-9074-279a2b6ba524 +mood,1587906020000,7D,0H,0,a748ee1a-1d0b-4ae9-9074-279a2b6ba524 +survey1,1587661220000,10H,10H,-1,a748ee1a-1d0b-4ae9-9074-279a2b6ba524 +survey2,1587661220000,10H,5H,-1,a748ee1a-1d0b-4ae9-9074-279a2b6ba524 +survey3,1587661220000,10H,0H,1,a748ee1a-1d0b-4ae9-9074-279a2b6ba524 + diff --git a/data/external/timesegments_periodic.csv b/data/external/timesegments_periodic.csv index c444224e..54ebdbbd 100644 --- a/data/external/timesegments_periodic.csv +++ b/data/external/timesegments_periodic.csv @@ -1,8 +1,9 @@ label,start_time,length,repeats_on,repeats_value -daily,00:00:00,23H 59M 59S,every_day,0 +threeday,00:00:00,2D 23H 59M 59S,every_day,0 +daily, 00:00:00,23H 59M 59S, every_day, 0 morning,06:00:00,5H 59M 59S,every_day,0 afternoon,12:00:00,5H 59M 59S,every_day,0 evening,18:00:00,5H 59M 59S,every_day,0 night,00:00:00,5H 59M 59S,every_day,0 two_weeks_overlapping,00:00:00,13D 23H 59M 59S,every_day,0 -weekends,00:00:00,1D 23H 59M 59S,wday,6 +weekends,00:00:00,2D 23H 59M 59S,wday,5 diff --git a/docs/developers/testing.md b/docs/developers/testing.md index 4d956738..a9e7f638 100644 --- a/docs/developers/testing.md +++ b/docs/developers/testing.md @@ -58,4 +58,213 @@ This python script `tests/scripts/run_tests.py` runs the tests. It parses the in ??? example "Example of raw data for PHONE_APPLICATIONS_FOREGROUND testing" ```json hl_lines="1 2 4" linenums="1" --8<---- "tests/data/external/aware_csv/phone_applications_foreground_raw.csv" - ``` \ No newline at end of file + ``` + +## What cases do we test? +The sample data includes 7 tests cases. Take phone battery as an example, on this platform, battery status 2 represents `charging` and battery status 4 represents `discharge`. + +??? "1. A daily segment instance with no battery episodes" + + ??? "Example" + + Input time segments: + + | timestamp | device_id | battery_status | battery_level | battery_scale | battery_voltage | battery_temperature | battery_adaptor | battery_health | battery_technology | + |---|---|---|---|---|---|---|---|---|---| + | 00:17:38.602 | test02 | 4 | 77 | 100 | 4157 | 23 | 0 | 2 | Li-ion | + | 03:20:30.415 | test02 | 2 | 77 | 100 | 4170 | 23 | 0 | 2 | Li-ion | + + Output results + + | local_segment | local_segment_label | local_segment_start_datetime | local_segment_end_datetime | phone_battery_rapids_countdischarge | phone_battery_rapids_sumdurationdischarge | phone_battery_rapids_avgconsumptionrate | phone_battery_rapids_maxconsumptionrate | phone_battery_rapids_countcharge | phone_battery_rapids_sumdurationcharge | + | --- |---|---|---|---|---|---|---|---|---| + | 00:00:00,00:29:59 | thirtyminutes0000 | 2020-07-01 00:00:00 | 2020-07-01 00:29:59 | 1 | 21.8259833333333 | 0.137450851775292 | 0.137450851775292 | 0 | 0 | + | 00:03:00,03:29:59 | thirtyminutes0006 | 2020-07-01 03:00:00 | 2020-07-01 03:29:59 | 0 | 0 | 0 | 0 | 1 | 9.49288333333333 | + + Since there is no battery episode between 00:00:30 and 03:00:00, no result will be generated for this epoch. + +??? "2. A daily segment instance with two battery episodes (one charging, one discharge)" + + ??? "Periodic (daily)" + + Input time segments: + + | timestamp | device_id | battery_status | battery_level | battery_scale | battery_voltage | battery_temperature | battery_adaptor | battery_health | battery_technology | + |-----------------------|-----------|----------------|---------------|---------------|-----------------|---------------------|-----------------|----------------|--------------------| + | 17:59:41.434 | test02 | 4 | 59 | 100 | 4094 | 23 | 0 | 2 | Li-ion | + | 18:04:14.321 | test02 | 4 | 58 | 100 | 4157 | 23 | 0 | 2 | Li-ion | + | 18:07:24.456 | test02 | 4 | 57 | 100 | 4157 | 23 | 0 | 2 | Li-ion | + | 20:03:03.415 | test02 | 2 | 72 | 100 | 4170 | 23 | 0 | 2 | Li-ion | + | 20:05:12.434 | test02 | 2 | 73 | 100 | 4094 | 23 | 0 | 2 | Li-ion | + | 20:07:24.678 | test02 | 2 | 74 | 100 | 4157 | 23 | 0 | 2 | Li-ion | + | 20:10:34.875 | test02 | 2 | 75 | 100 | 4157 | 23 | 0 | 2 | Li-ion | + | 21:30:04.415 | test02 | 4 | 74 | 100 | 4170 | 23 | 0 | 2 | Li-ion | + | 21:32:14.434 | test02 | 4 | 73 | 100 | 4094 | 23 | 0 | 2 | Li-ion | + | 21:35:23.678 | test02 | 4 | 72 | 100 | 4157 | 23 | 0 | 2 | Li-ion | + | 21:37:47.875 | test02 | 4 | 71 | 100 | 4157 | 23 | 0 | 2 | Li-ion | + + Output results: + + | local_segment | local_segment_label | local_segment_start_datetime | local_segment_end_datetime | phone_battery_rapids_countdischarge | phone_battery_rapids_sumdurationdischarge | phone_battery_rapids_avgconsumptionrate | phone_battery_rapids_maxconsumptionrate | phone_battery_rapids_countcharge | phone_battery_rapids_sumdurationcharge | + | --- |---|---|---|---|---|---|---|---|---| + | 18:00:00,23:59:59 | evening | 2020-07-01 18:00:00 | 2020-07-01 23:59:59 | 2 | 75.1306166666666 | 0.0664958369201784 | 0.079525673538274 | 1 | 37.5236666666667 | + + + ??? "Frequency (30 mins)" + + Input time segments: + + | timestamp | device_id | battery_status | battery_level | battery_scale | battery_voltage | battery_temperature | battery_adaptor | battery_health | battery_technology | + |---|---|---|---|---|---|---|---|---|---| + | 20:10:34.875 | test06 | 2 | 75 | 100 | 4157 | 23 | 0 | 2 | Li-ion | + | 20:20:17.171 | test06 | 4 | 74 | 100 | 4170 | 23 | 0 | 2 | Li-ion | + + Output results + + | local_segment | local_segment_label | local_segment_start_datetime | local_segment_end_datetime | phone_battery_rapids_countdischarge | phone_battery_rapids_sumdurationdischarge | phone_battery_rapids_avgconsumptionrate | phone_battery_rapids_maxconsumptionrate | phone_battery_rapids_countcharge | phone_battery_rapids_sumdurationcharge | + | --- |---|---|---|---|---|---|---|---|---| + | 20:00:00,20:29:59 | thirtyminutes0040 | 2020-07-01 20:00:00 | 2020-07-01 20:29:59 | 1 | 14.6351666666667 | 0.0683285693136395 | 0.0683285693136395 | 1 | 12.3074 | + + +??? "3. A daily segment instance with a charging episode that spans to the next daily instance" + + ??? "Periodic (daily)" + + Input time segments: + + | timestamp | device_id | battery_status | battery_level | battery_scale | battery_voltage | battery_temperature | battery_adaptor | battery_health | battery_technology | + |---|---|---|---|---|---|---|---|---|---| + | 11:59:28.434 | test02 | 2 | 63 | 100 | 4094 | 23 | 0 | 2 | Li-ion | + | 12:04:37.678 | test02 | 2 | 64 | 100 | 4157 | 23 | 0 | 2 | Li-ion | + + ??? "Frequency (30 mins)" + + Input time segements: + + | timestamp | device_id | battery_status | battery_level | battery_scale | battery_voltage | battery_temperature | battery_adaptor | battery_health | battery_technology | + |---|---|---|---|---|---|---|---|---|---| + | 11:59:28.434 | test06 | 2 | 63 | 100 | 4094 | 23 | 0 | 2 | Li-ion | + | 12:04:37.678 | test06 | 2 | 64 | 100 | 4157 | 23 | 0 | 2 | Li-ion | + +??? "4. A daily segment instance with a discharge episode that spans to the next daily instance" + + ??? "Periodic (daily)" + + Input time segements: + + | timestamp | device_id | battery_status | battery_level | battery_scale | battery_voltage | battery_temperature | battery_adaptor | battery_health | battery_technology | + |---|---|---|---|---|---|---|---|---|---| + | 05:59:49.434 | test02 | 4 | 79 | 100 | 4094 | 23 | 0 | 2 | Li-ion | + | 06:02:19.321 | test02 | 4 | 78 | 100 | 4157 | 23 | 0 | 2 | Li-ion | + + ??? "Frequency (30 mins)" + + Input time segements: + + | timestamp | device_id | battery_status | battery_level | battery_scale | battery_voltage | battery_temperature | battery_adaptor | battery_health | battery_technology | + |---|---|---|---|---|---|---|---|---|---| + | 17:59:41.434 | test06 | 4 | 59 | 100 | 4094 | 23 | 0 | 2 | Li-ion | + | 18:04:14.321 | test06 | 4 | 58 | 100 | 4157 | 23 | 0 | 2 | Li-ion | + +??? "5. Three-day segments that repeat everyday" + + [Time segment tested:](../setup/configuration.md#time-segments) + + | label | start_time | length | repeats_on | repeats_value | + |---|---|---|---|---| + | daily | 00:00:00 | 23H 59M 59S | every_day | 0 | + + + Data tested: + + We test 14 segments, one at the beginning of the first day, one at the end of the last day + + | timestamp | device_id | battery_status | battery_level | battery_scale | battery_voltage | battery_temperature | battery_adaptor | battery_health | battery_technology | + |-----------------------|-----------|----------------|---------------|---------------|-----------------|---------------------|-----------------|----------------|--------------------| + | 2020-07-02 00:03:47.875 | test01 | 3 | 63 | 100 | 4157 | 23 | 0 | 2 | Li-ion | + | 2020-07-02 00:05:47.875 | test01 | 3 | 62 | 100 | 4157 | 23 | 0 | 2 | Li-ion | + | 2020-07-02 23:55:47.875 | test01 | 3 | 55 | 100 | 4157 | 23 | 0 | 2 | Li-ion | + | 2020-07-02 23:59:47.875 | test01 | 3 | 54 | 100 | 4157 | 23 | 0 | 2 | Li-ion | + | 2020-07-03 00:06:47.875 | test01 | 3 | 53 | 100 | 4157 | 23 | 0 | 2 | Li-ion | + | 2020-07-03 00:09:47.875 | test01 | 3 | 52 | 100 | 4157 | 23 | 0 | 2 | Li-ion | + | 2020-07-03 23:47:05.000 | test01 | 3 | 60 | 100 | 4157 | 23 | 0 | 2 | Li-ion | + | 2020-07-03 23:55:05.000 | test01 | 3 | 59 | 100 | 4157 | 23 | 0 | 2 | Li-ion | + | 2020-07-04 00:15:05.000 | test01 | 3 | 58 | 100 | 4157 | 23 | 0 | 2 | Li-ion | + | 2020-07-04 00:18:05.000 | test01 | 3 | 57 | 100 | 4157 | 23 | 0 | 2 | Li-ion | + | 2020-07-04 23:51:00.000 | test01 | 3 | 41 | 100 | 4157 | 23 | 0 | 2 | Li-ion | + | 2020-07-04 23:57:00.000 | test01 | 3 | 40 | 100 | 4157 | 23 | 0 | 2 | Li-ion | + | 2020-07-05 00:21:00.000 | test01 | 3 | 39 | 100 | 4157 | 23 | 0 | 2 | Li-ion | + | 2020-07-05 00:23:00.000 | test01 | 3 | 38 | 100 | 4157 | 23 | 0 | 2 | Li-ion | + + + Output results: + + | local_segment | local_segment_label | local_segment_start_datetime | local_segment_end_datetime | phone_battery_rapids_countdischarge | phone_battery_rapids_sumdurationdischarge | phone_battery_rapids_avgconsumptionrate | phone_battery_rapids_maxconsumptionrate | phone_battery_rapids_countcharge | phone_battery_rapids_sumdurationcharge | + |--------------------------------------------------|---------------------|------------------------------|----------------------------|-------------------------------------|-------------------------------------------|-----------------------------------------|-----------------------------------------|----------------------------------|----------------------------------------| + | threeday#2020-07-02 00:00:00,2020-07-04 23:59:59 | threeday | 2020-07-02 00:00:00 | 2020-07-04 23:59:59 | 4 | 149.7954 | 0.0710868450815781 | 0.111113168762384 | 0 | 0 | + | threeday#2020-07-03 00:00:00,2020-07-05 23:59:59 | threeday | 2020-07-03 00:00:00 | 2020-07-05 23:59:59 | 3 | 162.7952 | 0.0492745931499224 | 0.0502547286558745 | 0 | 0 | + | threeday#2020-07-04 00:00:00,2020-07-06 23:59:59 | threeday | 2020-07-04 00:00:00 | 2020-07-06 23:59:59 | 2 | 110.0815 | 0.0449915246814979 | 0.0483879032392475 | 0 | 0 | + | threeday#2020-07-05 00:00:00,2020-07-07 23:59:59 | threeday | 2020-07-05 00:00:00 | 2020-07-07 23:59:59 | 1 | 52.9991166666667 | 0.0377364779979038 | 0.0377364779979038 | 0 | 0 | + +??? "6. A three-day segment that repeats on a fixed day" + + [Time segment tested:](../setup/configuration.md#time-segments) + + | label | start_time | length | repeats_on | repeats_value | + |---|---|---|---|---| + | weekends | 00:00:00 | 2D 23H 59M 59S | wday | 5 | + + Data tested: + + We test 10 segments, one at the beginning of the first day, one at the end of the last day + + | timestamp | device_id | battery_status | battery_level | battery_scale | battery_voltage | battery_temperature | battery_adaptor | battery_health | battery_technology | + |-----------------------|-----------|----------------|---------------|---------------|-----------------|---------------------|-----------------|----------------|--------------------| + | 2020-07-03 00:06:47.875 | test01 | 3 | 53 | 100 | 4157 | 23 | 0 | 2 | Li-ion | + | 2020-07-03 00:09:47.875 | test01 | 3 | 52 | 100 | 4157 | 23 | 0 | 2 | Li-ion | + | 2020-07-03 23:47:05.000 | test01 | 3 | 60 | 100 | 4157 | 23 | 0 | 2 | Li-ion | + | 2020-07-03 23:55:05.000 | test01 | 3 | 59 | 100 | 4157 | 23 | 0 | 2 | Li-ion | + | 2020-07-04 00:15:05.000 | test01 | 3 | 58 | 100 | 4157 | 23 | 0 | 2 | Li-ion | + | 2020-07-04 00:18:05.000 | test01 | 3 | 57 | 100 | 4157 | 23 | 0 | 2 | Li-ion | + | 2020-07-04 23:51:00.000 | test01 | 3 | 41 | 100 | 4157 | 23 | 0 | 2 | Li-ion | + | 2020-07-04 23:57:00.000 | test01 | 3 | 40 | 100 | 4157 | 23 | 0 | 2 | Li-ion | + | 2020-07-05 00:21:00.000 | test01 | 3 | 39 | 100 | 4157 | 23 | 0 | 2 | Li-ion | + | 2020-07-05 00:23:00.000 | test01 | 3 | 38 | 100 | 4157 | 23 | 0 | 2 | Li-ion | + + Output results: + + | local_segment | local_segment_label | local_segment_start_datetime | local_segment_end_datetime | phone_battery_rapids_countdischarge | phone_battery_rapids_sumdurationdischarge | phone_battery_rapids_avgconsumptionrate | phone_battery_rapids_maxconsumptionrate | phone_battery_rapids_countcharge | phone_battery_rapids_sumdurationcharge | + |--------------------------------------------------|---------------------|------------------------------|----------------------------|-------------------------------------|-------------------------------------------|-----------------------------------------|-----------------------------------------|----------------------------------|----------------------------------------| + | weekends#2020-07-03 00:00:00,2020-07-05 23:59:59 | weekends | 2020-07-03 00:00:00 | 2020-07-05 23:59:59 | 3 | 162.7952 | 0.0492745931499224 | 0.0502547286558745 | 0 | 0 | + +??? "7. Event segements" + + [Time segments tested:](../setup/configuration.md#time-segments) + + | label | event_timestamp | length | shift | shift_direction | device_id | + |---|---|---|---|---|---| + | survey1 | 1587661220000 | 10H | 10H | -1 | a748ee1a-1d0b-4ae9-9074-279a2b6ba524 | + | survey2 | 1587661220000 | 10H | 5H | -1 | a748ee1a-1d0b-4ae9-9074-279a2b6ba524 | + | survey3 | 1587661220000 | 10H | 0H | 1 | a748ee1a-1d0b-4ae9-9074-279a2b6ba524 | + + Data tested: + + We test 7 segments, one at the beginning of the first day, one at the end of the last day + + | timestamp | device_id | battery_status | battery_level | battery_scale | battery_voltage | battery_temperature | battery_adaptor | battery_health | battery_technology | + |-----------------------|--------------------------------------|----------------|---------------|---------------|-----------------|---------------------|-----------------|----------------|--------------------| + | 2020-04-23 03:15:00.000 | a748ee1a-1d0b-4ae9-9074-279a2b6ba524 | 3 | 90 | 100 | 4157 | 23 | 0 | 2 | Li-ion | + | 2020-04-23 03:21:00.000 | a748ee1a-1d0b-4ae9-9074-279a2b6ba524 | 3 | 89 | 100 | 4157 | 23 | 0 | 2 | Li-ion | + | 2020-04-23 07:50:00.000 | a748ee1a-1d0b-4ae9-9074-279a2b6ba524 | 3 | 80 | 100 | 4157 | 23 | 0 | 2 | Li-ion | + | 2020-04-23 08:05:00.000 | a748ee1a-1d0b-4ae9-9074-279a2b6ba524 | 3 | 79 | 100 | 4157 | 23 | 0 | 2 | Li-ion | + | 2020-04-23 08:12:00.000 | a748ee1a-1d0b-4ae9-9074-279a2b6ba524 | 3 | 78 | 100 | 4157 | 23 | 0 | 2 | Li-ion | + | 2020-04-23 22:50:00.000 | a748ee1a-1d0b-4ae9-9074-279a2b6ba524 | 3 | 50 | 100 | 4157 | 23 | 0 | 2 | Li-ion | + | 2020-04-23 22:53:00.000 | a748ee1a-1d0b-4ae9-9074-279a2b6ba524 | 3 | 49 | 100 | 4157 | 23 | 0 | 2 | Li-ion | + + Output results: + + | local_segment | local_segment_label | local_segment_start_datetime | local_segment_end_datetime | phone_battery_rapids_sumdurationcharge | phone_battery_rapids_countdischarge | phone_battery_rapids_sumdurationdischarge | phone_battery_rapids_maxconsumptionrate | phone_battery_rapids_avgconsumptionrate | phone_battery_rapids_countcharge | + |-------------------------------------------------|---------------------|------------------------------|----------------------------|----------------------------------------|-------------------------------------|-------------------------------------------|-----------------------------------------|-----------------------------------------|----------------------------------| + | survey1#2020-04-23 03:00:20,2020-04-23 13:00:20 | survey1 | 2020-04-23 03:00:20 | 2020-04-23 13:00:20 | 0 | 2 | 87.9985333333333 | 0.0384621794978634 | 0.0331202101231602 | 0 | + | survey2#2020-04-23 08:00:20,2020-04-23 18:00:20 | survey2 | 2020-04-23 08:00:20 | 2020-04-23 18:00:20 | 0 | 1 | 41.6659833333333 | 0.0480007872129103 | 0.0480007872129103 | 0 | + | survey3#2020-04-23 13:00:20,2020-04-23 23:00:20 | survey3 | 2020-04-23 13:00:20 | 2020-04-23 23:00:20 | 0 | 1 | 10.3498 | 0.0966202245454018 | 0.0966202245454018 | 0 | diff --git a/docs/stylesheets/extra.css b/docs/stylesheets/extra.css index 331aa97e..91707625 100644 --- a/docs/stylesheets/extra.css +++ b/docs/stylesheets/extra.css @@ -29,4 +29,5 @@ div[data-md-component=announce]>div#announce-msg>a{ .md-typeset table:not([class]) th { min-width: 0rem; -} \ No newline at end of file +} + diff --git a/tests/data/external/aware_csv/phone_battery_raw.csv b/tests/data/external/aware_csv/phone_battery_raw.csv index 4bca2c31..f29abf90 100644 --- a/tests/data/external/aware_csv/phone_battery_raw.csv +++ b/tests/data/external/aware_csv/phone_battery_raw.csv @@ -186,4 +186,31 @@ timestamp,device_id,battery_status,battery_level,battery_scale,battery_voltage,b 1593653404416.0,test06,4.0,72.0,100.0,4170.0,23.0,0.0,2.0,Li-ion 1593653534435.0,test06,4.0,71.0,100.0,4094.0,23.0,0.0,2.0,Li-ion 1593653723679.0,test06,4.0,70.0,100.0,4157.0,23.0,0.0,2.0,Li-ion -1593653867876.0,test06,4.0,69.0,100.0,4157.0,23.0,0.0,2.0,Li-ion \ No newline at end of file +1593653867876.0,test06,4.0,69.0,100.0,4157.0,23.0,0.0,2.0,Li-ion +,,,,,,,,, +1593662267875,test01,3,65,100,4157,23,0,2,Li-ion +1593662327875,test01,3,64,100,4157,23,0,2,Li-ion +1593662627875,test01,3,63,100,4157,23,0,2,Li-ion +1593662747875,test01,3,62,100,4157,23,0,2,Li-ion +,,,,,,,,, +1593748547875,test01,3,55,100,4157,23,0,2,Li-ion +1593748787875,test01,3,54,100,4157,23,0,2,Li-ion +1593749207875,test01,3,53,100,4157,23,0,2,Li-ion +1593749387875,test01,3,52,100,4157,23,0,2,Li-ion +,,,,,,,,, +1593834425001,test01,3,60,100,4157,23,0,2,Li-ion +1593834905001,test01,3,59,100,4157,23,0,2,Li-ion +1593836105001,test01,3,58,100,4157,23,0,2,Li-ion +1593836285001,test01,3,57,100,4157,23,0,2,Li-ion +1593921060001,test01,3,41,100,4157,23,0,2,Li-ion +1593921420001,test01,3,40,100,4157,23,0,2,Li-ion +1593922860001,test01,3,39,100,4157,23,0,2,Li-ion +1593922980001,test01,3,38,100,4157,23,0,2,Li-ion +,,,,,,,,, +1587626100001,a748ee1a-1d0b-4ae9-9074-279a2b6ba524,3,90,100,4157,23,0,2,Li-ion +1587626460001,a748ee1a-1d0b-4ae9-9074-279a2b6ba524,3,89,100,4157,23,0,2,Li-ion +1587642600001,a748ee1a-1d0b-4ae9-9074-279a2b6ba524,3,80,100,4157,23,0,2,Li-ion +1587643500001,a748ee1a-1d0b-4ae9-9074-279a2b6ba524,3,79,100,4157,23,0,2,Li-ion +1587643920001,a748ee1a-1d0b-4ae9-9074-279a2b6ba524,3,78,100,4157,23,0,2,Li-ion +1587696600001,a748ee1a-1d0b-4ae9-9074-279a2b6ba524,3,50,100,4157,23,0,2,Li-ion +1587696780001,a748ee1a-1d0b-4ae9-9074-279a2b6ba524,3,49,100,4157,23,0,2,Li-ion \ No newline at end of file diff --git a/tests/data/external/participant_files/test07.yaml b/tests/data/external/participant_files/test07.yaml new file mode 100644 index 00000000..40a9debc --- /dev/null +++ b/tests/data/external/participant_files/test07.yaml @@ -0,0 +1,6 @@ +PHONE: + DEVICE_IDS: [a748ee1a-1d0b-4ae9-9074-279a2b6ba524] + PLATFORMS: [android] + LABEL: test01 android + START_DATE: 2020/01/01 + END_DATE: 2020/08/01 \ No newline at end of file diff --git a/tests/data/processed/features/event/test07/phone_battery.csv b/tests/data/processed/features/event/test07/phone_battery.csv new file mode 100644 index 00000000..c6001147 --- /dev/null +++ b/tests/data/processed/features/event/test07/phone_battery.csv @@ -0,0 +1,4 @@ +"local_segment","local_segment_label","local_segment_start_datetime","local_segment_end_datetime","phone_battery_rapids_sumdurationdischarge","phone_battery_rapids_countcharge","phone_battery_rapids_sumdurationcharge","phone_battery_rapids_maxconsumptionrate","phone_battery_rapids_avgconsumptionrate","phone_battery_rapids_countdischarge" +"survey1#2020-04-23 03:00:20,2020-04-23 13:00:20","survey1","2020-04-23 03:00:20","2020-04-23 13:00:20",87.9985333333333,0,0,0.0384621794978634,0.0331202101231602,2 +"survey2#2020-04-23 08:00:20,2020-04-23 18:00:20","survey2","2020-04-23 08:00:20","2020-04-23 18:00:20",41.6659833333333,0,0,0.0480007872129103,0.0480007872129103,1 +"survey3#2020-04-23 13:00:20,2020-04-23 23:00:20","survey3","2020-04-23 13:00:20","2020-04-23 23:00:20",10.3498,0,0,0.0966202245454018,0.0966202245454018,1 diff --git a/tests/data/processed/features/periodic/test01/phone_battery.csv b/tests/data/processed/features/periodic/test01/phone_battery.csv index 1ca6d8ac..65b7d933 100644 --- a/tests/data/processed/features/periodic/test01/phone_battery.csv +++ b/tests/data/processed/features/periodic/test01/phone_battery.csv @@ -1,6 +1,28 @@ "local_segment","local_segment_label","local_segment_start_datetime","local_segment_end_datetime","phone_battery_rapids_countdischarge","phone_battery_rapids_sumdurationdischarge","phone_battery_rapids_avgconsumptionrate","phone_battery_rapids_maxconsumptionrate","phone_battery_rapids_countcharge","phone_battery_rapids_sumdurationcharge" "afternoon#2020-07-01 12:00:00,2020-07-01 17:59:59","afternoon","2020-07-01 12:00:00","2020-07-01 17:59:59",2,42.1548666666667,0.165910502035002,0.253301361072647,2,79.4708833333333 -"daily#2020-07-01 00:00:00,2020-07-01 23:59:59","daily","2020-07-01 00:00:00","2020-07-01 23:59:59",6,234.816433333333,0.0767871798602915,0.0809973837845038,5,199.701516666667 -"evening#2020-07-01 18:00:00,2020-07-01 23:59:59","evening","2020-07-01 18:00:00","2020-07-01 23:59:59",2,75.1306166666666,0.0664958369201784,0.079525673538274,1,37.5236666666667 +"daily#2020-07-01 00:00:00,2020-07-01 23:59:59","daily","2020-07-01 00:00:00","2020-07-01 23:59:59",7,237.018466666667,0.130692687348499,0.454125732277743,5,199.701516666667 +"daily#2020-07-02 00:00:00,2020-07-02 23:59:59","daily","2020-07-02 00:00:00","2020-07-02 23:59:59",2,39.9993166666667,0.146926011409736,0.237981913374584,0,0 +"daily#2020-07-03 00:00:00,2020-07-03 23:59:59","daily","2020-07-03 00:00:00","2020-07-03 23:59:59",2,52.7136833333333,0.0638377410315164,0.0774207534071583,0,0 +"daily#2020-07-04 00:00:00,2020-07-04 23:59:59","daily","2020-07-04 00:00:00","2020-07-04 23:59:59",2,57.0823666666667,0.0763541574430664,0.111113168762384,0,0 +"daily#2020-07-05 00:00:00,2020-07-05 23:59:59","daily","2020-07-05 00:00:00","2020-07-05 23:59:59",1,52.9991166666667,0.0377364779979038,0.0377364779979038,0,0 +"evening#2020-07-01 18:00:00,2020-07-01 23:59:59","evening","2020-07-01 18:00:00","2020-07-01 23:59:59",3,77.33265,0.195705802039367,0.454125732277743,1,37.5236666666667 +"evening#2020-07-02 18:00:00,2020-07-02 23:59:59","evening","2020-07-02 18:00:00","2020-07-02 23:59:59",1,4.202,0.237981913374584,0.237981913374584,0,0 +"evening#2020-07-03 18:00:00,2020-07-03 23:59:59","evening","2020-07-03 18:00:00","2020-07-03 23:59:59",1,12.9164333333333,0.0774207534071583,0.0774207534071583,0,0 +"evening#2020-07-04 18:00:00,2020-07-04 23:59:59","evening","2020-07-04 18:00:00","2020-07-04 23:59:59",1,8.99983333333333,0.111113168762384,0.111113168762384,0,0 "morning#2020-07-01 06:00:00,2020-07-01 11:59:59","morning","2020-07-01 06:00:00","2020-07-01 11:59:59",2,75.56395,0.065515964597609,0.0731286084397727,2,42.61665 "night#2020-07-01 00:00:00,2020-07-01 05:59:59","night","2020-07-01 00:00:00","2020-07-01 05:59:59",2,41.9669666666667,0.23817390645112,0.400338953647421,1,40.0903 +"night#2020-07-02 00:00:00,2020-07-02 05:59:59","night","2020-07-02 00:00:00","2020-07-02 05:59:59",1,35.7973166666667,0.0558701094448886,0.0558701094448886,0,0 +"night#2020-07-03 00:00:00,2020-07-03 05:59:59","night","2020-07-03 00:00:00","2020-07-03 05:59:59",1,39.79725,0.0502547286558745,0.0502547286558745,0,0 +"night#2020-07-04 00:00:00,2020-07-04 05:59:59","night","2020-07-04 00:00:00","2020-07-04 05:59:59",1,48.0825333333333,0.0415951461237483,0.0415951461237483,0,0 +"night#2020-07-05 00:00:00,2020-07-05 05:59:59","night","2020-07-05 00:00:00","2020-07-05 05:59:59",1,52.9991166666667,0.0377364779979038,0.0377364779979038,0,0 +"threeday#2020-07-01 00:00:00,2020-07-03 23:59:59","threeday","2020-07-01 00:00:00","2020-07-03 23:59:59",9,329.7315,0.0761417190406398,0.0809973837845038,5,199.701516666667 +"threeday#2020-07-02 00:00:00,2020-07-04 23:59:59","threeday","2020-07-02 00:00:00","2020-07-04 23:59:59",4,149.7954,0.0710868450815781,0.111113168762384,0,0 +"threeday#2020-07-03 00:00:00,2020-07-05 23:59:59","threeday","2020-07-03 00:00:00","2020-07-05 23:59:59",3,162.7952,0.0492745931499224,0.0502547286558745,0,0 +"threeday#2020-07-04 00:00:00,2020-07-06 23:59:59","threeday","2020-07-04 00:00:00","2020-07-06 23:59:59",2,110.0815,0.0449915246814979,0.0483879032392475,0,0 +"threeday#2020-07-05 00:00:00,2020-07-07 23:59:59","threeday","2020-07-05 00:00:00","2020-07-07 23:59:59",1,52.9991166666667,0.0377364779979038,0.0377364779979038,0,0 +"two_weeks_overlapping#2020-07-01 00:00:00,2020-07-14 23:59:59","two_weeks_overlapping","2020-07-01 00:00:00","2020-07-14 23:59:59",10,439.813016666667,0.0705423768752492,0.0809973837845038,5,199.701516666667 +"two_weeks_overlapping#2020-07-02 00:00:00,2020-07-15 23:59:59","two_weeks_overlapping","2020-07-02 00:00:00","2020-07-15 23:59:59",4,202.794533333333,0.0554055287007939,0.0681829545643943,0,0 +"two_weeks_overlapping#2020-07-03 00:00:00,2020-07-16 23:59:59","two_weeks_overlapping","2020-07-03 00:00:00","2020-07-16 23:59:59",3,162.7952,0.0492745931499224,0.0502547286558745,0,0 +"two_weeks_overlapping#2020-07-04 00:00:00,2020-07-17 23:59:59","two_weeks_overlapping","2020-07-04 00:00:00","2020-07-17 23:59:59",2,110.0815,0.0449915246814979,0.0483879032392475,0,0 +"two_weeks_overlapping#2020-07-05 00:00:00,2020-07-18 23:59:59","two_weeks_overlapping","2020-07-05 00:00:00","2020-07-18 23:59:59",1,52.9991166666667,0.0377364779979038,0.0377364779979038,0,0 +"weekends#2020-07-03 00:00:00,2020-07-05 23:59:59","weekends","2020-07-03 00:00:00","2020-07-05 23:59:59",3,162.7952,0.0492745931499224,0.0502547286558745,0,0 diff --git a/tests/scripts/run_tests.py b/tests/scripts/run_tests.py index c52c7bc6..8e0fa90a 100644 --- a/tests/scripts/run_tests.py +++ b/tests/scripts/run_tests.py @@ -76,6 +76,14 @@ class TestPeriodic(RapidsTests): with open(r'tests/settings/periodic_config.yaml') as file: cls.configs = yaml.full_load(file) +class TestEvent(RapidsTests): + @classmethod + def setUpClass(cls): + # Runs once to Setup env + # global configs + with open(r'tests/settings/event_config.yaml') as file: + cls.configs = yaml.full_load(file) + def run_some_tests(test_type): # Run only the tests in the specified classes @@ -83,6 +91,8 @@ def run_some_tests(test_type): test_class = TestFrequency elif test_type == "periodic": test_class = TestPeriodic + elif test_type == "event": + test_class = TestEvent else: raise ValueError("Only frequency or periodic are valid arguments") loader = unittest.TestLoader() diff --git a/tests/scripts/run_tests.sh b/tests/scripts/run_tests.sh index aa96f376..c2e5a906 100755 --- a/tests/scripts/run_tests.sh +++ b/tests/scripts/run_tests.sh @@ -4,6 +4,9 @@ run_pipeline() { if [ $TYPE == 'frequency' ] then CONFIG_FILE="./tests/settings/frequency_config.yaml" + elif [ $TYPE == 'event' ] + then + CONFIG_FILE="./tests/settings/event_config.yaml" else CONFIG_FILE="./tests/settings/periodic_config.yaml" fi @@ -47,7 +50,7 @@ case $key in esac done -if [ $ACTION != 'test' ] && [ $ACTION != 'run' ] && [ $ACTION != 'both' ] +if [ $ACTION != 'test' ] && [ $ACTION != 'run' ] && [ $ACTION != 'both' ] then display_usage fi @@ -61,7 +64,7 @@ then run_pipeline python tests/scripts/run_tests.py periodic else - if [ $TYPE != 'frequency' ] && [ $TYPE != 'periodic' ] + if [ $TYPE != 'frequency' ] && [ $TYPE != 'periodic' ] && [ $TYPE != 'event' ] then display_usage fi diff --git a/tests/settings/event_config.yaml b/tests/settings/event_config.yaml index 96406fa2..73350164 100644 --- a/tests/settings/event_config.yaml +++ b/tests/settings/event_config.yaml @@ -3,7 +3,7 @@ ######################################################################################################################## # See https://www.rapids.science/latest/setup/configuration/#participant-files -PIDS: [test01, test03, test04] +PIDS: [test07] # See https://www.rapids.science/latest/setup/configuration/#automatic-creation-of-participant-files CREATE_PARTICIPANT_FILES: