def test_update_02(self): # Try to update deltarepos.xml.xz (deletion of a repo) dir = tempfile.mkdtemp(prefix="update_02-", dir=self.tmpdir) path = os.path.join(dir, "deltarepos.xml.xz") first = cp(DELTAREPO_01_01, dir) cp(DELTAREPO_01_02, dir) ret = gen_deltarepos_file(dir, self.logger) self.assertEqual(ret, path) self.assertTrue(os.path.isfile(path)) dr = DeltaRepos() dr.load(path) self.assertEqual(len(dr.records), 2) rec = dr.records[0] self.assertEqual(rec.location_href, os.path.basename(DELTAREPO_01_01)) rec = dr.records[1] self.assertEqual(rec.location_href, os.path.basename(DELTAREPO_01_02)) shutil.rmtree(first) ret = gen_deltarepos_file(dir, self.logger, update=True) self.assertEqual(ret, path) self.assertTrue(os.path.isfile(path)) dr = DeltaRepos() dr.load(path) self.assertEqual(len(dr.records), 1) rec = dr.records[0] self.assertEqual(rec.location_href, os.path.basename(DELTAREPO_01_02))
def test_one_repo(self): # Try to generate deltarepos.xml.xz for a directory with one repo dir = tempfile.mkdtemp(prefix="one_repo-", dir=self.tmpdir) path = os.path.join(dir, "deltarepos.xml.xz") cp(DELTAREPO_01_01, dir) ret = gen_deltarepos_file(dir, self.logger) self.assertEqual(ret, path) self.assertTrue(os.path.isfile(path)) dr = DeltaRepos() dr.load(path) self.assertEqual(len(dr.records), 1) rec = dr.records[0] self.assertEqual(rec.location_href, os.path.basename(DELTAREPO_01_01))