feat(android): warm voice interface and custom sampling up to one day v0.1.51
This commit is contained in:
@@ -143,5 +143,43 @@ class LocationSyncTests(unittest.TestCase):
|
||||
phone=self.enabled(intervalSeconds=3*86400);started=phone['collectionStartedAt'];app.LOCATIONS.latest.clear()
|
||||
with patch('member_locations.time.time',return_value=started+86400):self.assertEqual(app.LOCATIONS.listing(self.aid,user=self.owner)[0]['status'],'scheduled')
|
||||
|
||||
def test_custom_sampling_roundtrips_independently_and_limits_one_day(self):
|
||||
phone=self.phone('自定义采集')
|
||||
for sample in (10,30,120,420,900,1800,3600,7200,10800,14400,18000,25200,43200,86400):
|
||||
response=self.configure(phone,viewerIds=[self.owner['id']],intervalSeconds=300,sampleIntervalSeconds=sample)
|
||||
self.assertEqual(response['sampleIntervalSeconds'],sample)
|
||||
self.assertEqual(response['intervalSeconds'],300)
|
||||
settings=app.LOCATIONS.native(phone['token'],dict(action='settings'))
|
||||
self.assertEqual(settings['sampleIntervalSeconds'],sample)
|
||||
for invalid in (True,0,9,86401,7*86400,3600.0,'3600',None):
|
||||
with self.assertRaises(app.Problem):self.configure(phone,viewerIds=[self.owner['id']],sampleIntervalSeconds=invalid)
|
||||
|
||||
def test_daily_sampling_wait_and_overdue_are_distinct_from_upload(self):
|
||||
phone=self.enabled(intervalSeconds=300,sampleIntervalSeconds=86400);started=phone['collectionStartedAt']
|
||||
with patch('member_locations.time.time',return_value=started+3600):
|
||||
row=app.LOCATIONS.listing(self.aid,user=self.owner)[0]
|
||||
self.assertEqual(row['status'],'scheduled');self.assertEqual(row['scheduleReason'],'sampling')
|
||||
self.assertEqual(row['nextSampleAt'],started+86400);self.assertIsNone(row['position'])
|
||||
# Heartbeats must not postpone the next scheduled collection indefinitely.
|
||||
app.LOCATIONS.latest[phone['sid']]['seen']=started+86400+901
|
||||
with patch('member_locations.time.time',return_value=started+86400+901):
|
||||
self.assertEqual(app.LOCATIONS.listing(self.aid,user=self.owner)[0]['status'],'stale')
|
||||
|
||||
def test_last_sample_schedule_survives_restart_without_persisting_coordinates(self):
|
||||
phone=self.enabled(intervalSeconds=300,sampleIntervalSeconds=86400);started=phone['collectionStartedAt']
|
||||
with app.DB:app.LOCATIONS.sync.seen(phone['sid'],started,started+86400,started+86400)
|
||||
app.LOCATIONS.latest.clear()
|
||||
with patch('member_locations.time.time',return_value=started+86400+3600):
|
||||
row=app.LOCATIONS.listing(self.aid,user=self.owner)[0];self.assertEqual(row['status'],'scheduled')
|
||||
self.assertEqual(row['nextSampleAt'],started+2*86400);self.assertIsNone(row['position'])
|
||||
|
||||
def test_upload_timing_migration_preserves_existing_schedule(self):
|
||||
with app.DB:
|
||||
app.DB.execute('DROP TABLE location_upload_timing')
|
||||
app.DB.execute('CREATE TABLE location_upload_timing (share_id TEXT PRIMARY KEY,started REAL,last_received REAL)')
|
||||
app.DB.execute('INSERT INTO location_upload_timing VALUES (?,?,?)',('old-phone',100,200))
|
||||
app.LOCATIONS.sync.initialize();app.LOCATIONS.sync.initialize()
|
||||
self.assertEqual(app.LOCATIONS.sync.timing('old-phone'),dict(started=100,seen=200,sampleAt=0))
|
||||
|
||||
|
||||
if __name__=='__main__':unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user