def test_no_unknown_patch_versions(self): """ L{PatchApplier.get_unknown_patch_versions} returns an empty set if no patches are unapplied. """ patches = [Patch(42), Patch(380)] my_store = MockPatchStore("database", patches=patches) patch_applier = PatchApplier(my_store, self.mypackage) self.assertEqual(set(), patch_applier.get_unknown_patch_versions())
def test_get_unknown_patch_versions(self): """ L{PatchApplier.get_unknown_patch_versions} returns the versions of all unapplied patches. """ patches = [Patch(42), Patch(380), Patch(381)] my_store = MockPatchStore("database", patches=patches) patch_applier = PatchApplier(my_store, self.mypackage) self.assertEqual(set([381]), patch_applier.get_unknown_patch_versions())
def getPatchStatus(store, schema): """Get the patch status for a database. @param store: The C{Store} for the database. @param schema: The Storm C{Schema} for the database. @return: A L{PatchStatus} instance with information about the patch level of the database. """ # FIXME It's a bit unfortunate that we're accessing private attributes and # methods of Schema and PatchApplier in this code, but there's no way to # get the information we need with the public API. This is really a bug # in Storm, see bug #754468 for more details about it. patchApplier = PatchApplier(store, schema._patch_package) unappliedPatches = sorted(patchApplier._get_unapplied_versions()) unknownPatches = sorted(patchApplier.get_unknown_patch_versions()) return PatchStatus(unappliedPatches, unknownPatches)