def test_dump_deltametadata_01(self): plugin = PluginBundle("FooBarPlugin", 1) plugin.set("database", "1") plugin.set("origincompression", "gz") plugin.append("removedpackage", {"href": "Pacakges/foo.rpm", "base": "ftp://foobaar/"}) plugin.append("removedpackage", {"href": "Packages/bar.rpm"}) plugin.append("emptylist", {}) dm = DeltaMetadata() dm.revision_src = "123" dm.revision_dst = "456" dm.contenthash_src = "abc" dm.contenthash_dst = "bcd" dm.contenthash_type = "foobar" dm.timestamp_src = 120 dm.timestamp_dst = 450 dm.add_pluginbundle(plugin) content = dm.dumps() path = os.path.join(self.tmpdir, "01.xml") open(path, "w").write(content) dm_loaded = DeltaMetadata() dm_loaded.load(path) self.assertEqual(dm.revision_src, dm_loaded.revision_src) self.assertEqual(dm.revision_dst, dm_loaded.revision_dst) self.assertEqual(dm.contenthash_src, dm_loaded.contenthash_src) self.assertEqual(dm.contenthash_dst, dm_loaded.contenthash_dst) self.assertEqual(dm.contenthash_type, dm_loaded.contenthash_type) self.assertEqual(dm.timestamp_src, dm_loaded.timestamp_src) self.assertEqual(dm.timestamp_dst, dm_loaded.timestamp_dst) self.assertEqual(len(dm.usedplugins), len(dm_loaded.usedplugins)) self.assertEqual(dm.usedplugins["FooBarPlugin"].__dict__, dm_loaded.usedplugins["FooBarPlugin"].__dict__)
def test_dump_empty_deltametadata(self): dm = DeltaMetadata() content = dm.dumps() self.assertEqual(content, XML_EMPTY)