def _test_update(self, filename, contents, expected_new_contents, expected_updates): with tempfile.TemporaryDirectory() as tmpdir: manifest = os.path.join(tmpdir, filename) with open(manifest, "w") as f: f.write(contents) appdata = os.path.join( tmpdir, os.path.splitext(filename)[0] + ".appdata.xml", ) with open(appdata, "w") as f: f.write("""<application></application>""") checker = ManifestChecker(manifest) checker._checkers = [UpdateEverythingChecker()] checker.check() updates = checker.update_manifests() with open(manifest, "r") as f: new_contents = f.read() self.assertEqual(new_contents, expected_new_contents) self.assertEqual(updates, expected_updates) with open(appdata, "r") as f: appdata_doc = minidom.parse(f) releases = appdata_doc.getElementsByTagName("release") self.assertNotEqual(releases, []) self.assertEqual(releases, releases[:1]) self.assertEqual(releases[0].getAttribute("version"), "1.2.3.4") self.assertEqual(releases[0].getAttribute("date"), "2019-08-28")
def _test_remove(self, filename, contents, expected_new_contents, expected_updates): with tempfile.TemporaryDirectory() as tmpdir: manifest = os.path.join(tmpdir, filename) with open(manifest, "w") as f: f.write(contents) checker = ManifestChecker(manifest) checker._checkers = [RemoveEverythingChecker()] checker.check() updates = checker.update_manifests() with open(manifest, "r") as f: new_contents = f.read() self.assertEqual(new_contents, expected_new_contents) self.assertEqual(updates, expected_updates)