async def test_max_sync_interval_next_sync_attempt(coord: Coordinator, model, source: HelperTestSource, dest: HelperTestSource, snapshot, time: FakeTime, simple_config: Config): """ Next snapshot is after max sync interval is reached """ simple_config.override(Setting.DAYS_BETWEEN_SNAPSHOTS, 1) simple_config.override(Setting.MAX_SYNC_INTERVAL_SECONDS, 60 * 60) time.setTimeZone("Europe/Stockholm") simple_config.override(Setting.SNAPSHOT_TIME_OF_DAY, "03:23") simple_config.override(Setting.DAYS_BETWEEN_SNAPSHOTS, 1) source.setMax(10) source.insert("Fri", time.toUtc(time.local(2020, 3, 16, 3, 33))) time.setNow(time.local(2020, 3, 17, 1, 29)) model.reinitialize() coord.reset() await coord.sync() assert coord.nextSyncAttempt() == time.local(2020, 3, 17, 2, 29) assert coord.nextSnapshotTime() > coord.nextSyncAttempt()
async def test_alternate_timezone(coord: Coordinator, time: FakeTime, model: Model, dest, source, simple_config: Config): time.setTimeZone("Europe/Stockholm") simple_config.override(Setting.SNAPSHOT_TIME_OF_DAY, "12:00") simple_config.override(Setting.DAYS_BETWEEN_SNAPSHOTS, 1) source.setMax(10) source.insert("Fri", time.toUtc(time.local(2020, 3, 16, 18, 5))) time.setNow(time.local(2020, 3, 16, 18, 6)) model.reinitialize() coord.reset() await coord.sync() assert not coord.check() assert coord.nextSnapshotTime() == time.local(2020, 3, 17, 12) time.setNow(time.local(2020, 3, 17, 11, 59)) await coord.sync() assert not coord.check() time.setNow(time.local(2020, 3, 17, 12)) assert coord.check()