Testing¶
The following is a simple guide to run RAPIDS’ tests. All files necessary for testing are stored in the ./tests/
directory
Steps for Testing¶
- Add raw data.
- Add the raw data to the corresponding sensor CSV file in
tests/data/external/aware_csv
. Create the CSV if it does not exist.
- Add the raw data to the corresponding sensor CSV file in
- Link raw data.
- Make sure that you link the new raw data to a participant by using the same
device_id
in the data and in[DEVICE_IDS]
inside their participant file (tests/data/external/participant_files/testXX.yaml
). - Create the participant file if it does not exist, and don’t forget to edit
[PIDS]
in the config file of the time segments you are testing (see below). For simplicity, we use a participant’s id (testXX
) as theirdevice_id
.
- Make sure that you link the new raw data to a participant by using the same
- Edit the config file.
- Activate the sensor provider you are testing if it isn’t already. Set
[SENSOR][PROVIDER][COMPUTE]
toTRUE
in theconfig.yaml
of the time segments you are testing:- tests/settings/frequency_config.yaml # For frequency time segments - tests/settings/periodic_config.yaml # For periodic time segments # We have not tested events time segments yet
- Activate the sensor provider you are testing if it isn’t already. Set
- Run the pipeline and tests.
- You can run all time segments pipelines and their tests
tests/scripts/run_tests.sh -t all
- You can run only the pipeline of a specific time segment and its tests
tests/scripts/run_tests.sh -t frequency -a both
- Or, if you are working on your tests and you want to run a pipeline and its tests independently
tests/scripts/run_tests.sh -t frequency -a run tests/scripts/run_tests.sh -t frequency -a test
- You can run all time segments pipelines and their tests
Output example¶
The following is a snippet of the output you should see after running your test.
test_sensors_files_exist (test_sensor_features.TestSensorFeatures) ... periodic
ok
test_sensors_features_calculations (test_sensor_features.TestSensorFeatures) ... periodic
ok
test_sensors_files_exist (test_sensor_features.TestSensorFeatures) ... frequency
ok
test_sensors_features_calculations (test_sensor_features.TestSensorFeatures) ... frequency
FAIL
The results above show that the for periodic both test_sensors_files_exist
and test_sensors_features_calculations
passed while for frequency first test test_sensors_files_exist
passed while test_sensors_features_calculations
failed. Additionally, you should get the traceback of the failure (not shown here). For more information on how to implement test scripts and use unittest please see Unittest Documentation
Testing of the RAPIDS sensors and features is a work-in-progress. Please see Test Cases for a list of sensors and features that have testing currently available.
How do we execute the tests?¶
This bash script tests/scripts/run_tests.sh
executes one or all pipelines for different time segment types (frequency
, periodic
, and events
) as well as their tests (see below).
This python script tests/scripts/run_tests.py
runs the tests. It parses the involved participants and active sensor providers in the config.yaml
file of the time segment type being tested. We test that the output file we expect exists and that its content matches the expected values.
Example of raw data for PHONE_APPLICATIONS_FOREGROUND testing
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
|