@@ -27,6 +27,9 @@ class TestSecondary(unittest.TestCase):
2727 TEST_START_TIME_JERK = 1584137124130
2828 TEST_START_TIME_STEPS = 1651161331270 - 5 * MS_IN_DAY
2929 TEST_PARTICIPANT_CALLS = "U7955172051"
30+ TEST_PARTICIPANT_NEARBY_DEVICES = "U1753020007"
31+ NEARBY_TEST_START = 1646485947205
32+ NEARBY_TEST_END = 1647003793838
3033 CALLS_TEST_START = 1654781897000 + 10 * MS_IN_DAY
3134 CALLS_TEST_END = 1654781897001 + 11 * MS_IN_DAY
3235
@@ -35,16 +38,25 @@ def setUp(self):
3538 logger = logging .getLogger ()
3639 logger .setLevel (logging .CRITICAL )
3740
38- # 0. bluetooth_device_count
41+ # 0. nearby_device_count
3942 def test_device_count_no_data (self ):
4043 # Test if the participant has no data
41- ret0 = secondary .bluetooth_device_count . bluetooth_device_count (id = self .EMPTY_PARTICIPANT ,
44+ ret0 = secondary .nearby_device_count . nearby_device_count (id = self .EMPTY_PARTICIPANT ,
4245 start = self .TEST_END_TIME - 3 * self .MS_IN_DAY ,
4346 end = self .TEST_END_TIME ,
4447 resolution = self .MS_IN_DAY )
4548 for x in ret0 ['data' ]:
4649 self .assertEqual (x ['value' ], None )
4750
51+ def test_device_count_data (self ):
52+ # Test that nearby device count works
53+ ret0 = secondary .nearby_device_count .nearby_device_count (id = self .TEST_PARTICIPANT_NEARBY_DEVICES ,
54+ start = self .NEARBY_TEST_START ,
55+ end = self .NEARBY_TEST_END ,
56+ resolution = self .MS_IN_DAY )
57+ self .assertEqual (ret0 ['data' ][0 ]['value' ], 3 )
58+ self .assertEqual (ret0 ['data' ][1 ]['value' ], None )
59+
4860 # 1. data_quality
4961 def test_data_quality_no_data (self ):
5062 # Test if the participant has no data
@@ -151,8 +163,8 @@ def test_call_duration(self):
151163 local_ret = cortex .secondary .call_duration .call_duration (
152164 incoming = option ,
153165 id = self .TEST_PARTICIPANT_CALLS ,
154- start = self .CALLS_TEST_START - self . MS_IN_DAY ,
155- end = self .CALLS_TEST_END - self . MS_IN_DAY ,
166+ start = self .CALLS_TEST_START ,
167+ end = self .CALLS_TEST_END ,
156168 resolution = self .MS_IN_DAY ,
157169 feature = "telephony" )['data' ][0 ]['value' ]
158170 rets_incoming .append (local_ret )
@@ -163,7 +175,7 @@ def test_call_duration(self):
163175 self .assertEqual (rets [3 ], None )
164176 self .assertEqual (ret_none , None )
165177 self .assertEqual (rets_incoming [0 ], 34 )
166- self .assertEqual (rets_incoming [0 ], 24 )
178+ self .assertEqual (rets_incoming [1 ], 24 )
167179
168180 def test_call_number (self ):
169181 # Test that call number works
@@ -198,8 +210,8 @@ def test_call_number(self):
198210 local_ret = cortex .secondary .call_number .call_number (
199211 incoming = option ,
200212 id = self .TEST_PARTICIPANT_CALLS ,
201- start = self .CALLS_TEST_START - self . MS_IN_DAY ,
202- end = self .CALLS_TEST_END - self . MS_IN_DAY ,
213+ start = self .CALLS_TEST_START ,
214+ end = self .CALLS_TEST_END ,
203215 resolution = self .MS_IN_DAY ,
204216 feature = "telephony" )['data' ][0 ]['value' ]
205217 rets_incoming .append (local_ret )
@@ -210,7 +222,7 @@ def test_call_number(self):
210222 self .assertEqual (rets [3 ], None )
211223 self .assertEqual (ret_none , None )
212224 self .assertEqual (rets_incoming [0 ], 1 )
213- self .assertEqual (rets_incoming [0 ], 1 )
225+ self .assertEqual (rets_incoming [1 ], 1 )
214226
215227if __name__ == '__main__' :
216228 unittest .main ()
0 commit comments