async def test_never_delete_ignored_snapshots(time: FakeTime, model: Model, dest: HelperTestSource, source: HelperTestSource): source.setMax(1) dest.setMax(1) # A sync should create a snapshot and back it up to dest. await model.sync(time.now()) source.assertThat(created=1, current=1) dest.assertThat(saved=1, current=1) source.reset() dest.reset() # Another sync shoudl delete a snapshot, which is just a sanity check. time.advance(days=5) await model.sync(time.now()) source.assertThat(created=1, current=1, deleted=1) dest.assertThat(saved=1, current=1, deleted=1) assert model.nextSnapshot(time.now()) == time.now() + timedelta(days=3) source.reset() dest.reset() # Make the snapshot ignored, which should cause a new snapshot to be created # and synced without the ignored one getting deleted. next(iter((await dest.get()).values())).setIgnore(True) next(iter((await source.get()).values())).setIgnore(True) assert model.nextSnapshot(time.now()) < time.now() await model.sync(time.now()) source.assertThat(created=1, current=2) dest.assertThat(saved=1, current=2)
async def test_wait_for_startup_no_snapshot(time: FakeTime, model: Model, dest: HelperTestSource, source: HelperTestSource, global_info: GlobalInfo): time.setNow(time.local(2019, 5, 10)) global_info.triggerSnapshotCooldown(timedelta(minutes=10)) assert model.nextSnapshot(time.now()) == time.now() + timedelta(minutes=10) assert model.nextSnapshot(time.now()) == global_info.snapshotCooldownTime() assert model.waiting_for_startup time.advance(minutes=10) assert model.nextSnapshot(time.now()) == time.now() - timedelta(minutes=1) assert not model.waiting_for_startup
async def test_ignore_startup_delay(time: FakeTime, model: Model, dest: HelperTestSource, source: HelperTestSource, global_info: GlobalInfo): time.setNow(time.local(2019, 5, 10)) global_info.triggerSnapshotCooldown(timedelta(minutes=10)) model.ignore_startup_delay = True assert model.nextSnapshot(time.now()) == time.now() - timedelta(minutes=1) assert not model.waiting_for_startup