From: Hans-Christoph Steiner Date: Mon, 20 Jun 2016 11:41:30 +0000 (+0200) Subject: tests for finding the proper OBB files for each APK X-Git-Tag: 0.7.0~34^2 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=fdroidserver.git;a=commitdiff_plain;h=5f8beaa2c6b1553047d04c34bd9dec5c11715f62 tests for finding the proper OBB files for each APK --- diff --git a/tests/metadata/obb.main.oldversion.txt b/tests/metadata/obb.main.oldversion.txt new file mode 100644 index 00000000..56c4a9f5 --- /dev/null +++ b/tests/metadata/obb.main.oldversion.txt @@ -0,0 +1,12 @@ +Categories:Development +License:GPLv3 +Source Code:https://github.com/eighthave/urzip +Bitcoin:1Fi5xUHiAPRKxHvyUGVFGt9extBe8Srdbk + +Auto Name:OBB Main Old Version + +Repo Type:git +Repo:https://github.com/eighthave/urzip.git + + +Current Version Code:99999999 diff --git a/tests/metadata/obb.main.twoversions.txt b/tests/metadata/obb.main.twoversions.txt new file mode 100644 index 00000000..d06afa36 --- /dev/null +++ b/tests/metadata/obb.main.twoversions.txt @@ -0,0 +1,12 @@ +Categories:Development +License:GPLv3 +Source Code:https://github.com/eighthave/urzip +Bitcoin:1Fi5xUHiAPRKxHvyUGVFGt9extBe8Srdbk + +Auto Name:OBB Two Versions + +Repo Type:git +Repo:https://github.com/eighthave/urzip.git + + +Current Version Code:99999999 diff --git a/tests/metadata/obb.mainpatch.current.txt b/tests/metadata/obb.mainpatch.current.txt new file mode 100644 index 00000000..2f7571f5 --- /dev/null +++ b/tests/metadata/obb.mainpatch.current.txt @@ -0,0 +1,12 @@ +Categories:Development +License:GPLv3 +Source Code:https://github.com/eighthave/urzip +Bitcoin:1Fi5xUHiAPRKxHvyUGVFGt9extBe8Srdbk + +Auto Name:OBB Main+Patch Current Version + +Repo Type:git +Repo:https://github.com/eighthave/urzip.git + + +Current Version Code:99999999 diff --git a/tests/repo/main.1101613.obb.main.twoversions.obb b/tests/repo/main.1101613.obb.main.twoversions.obb new file mode 100644 index 00000000..421376db --- /dev/null +++ b/tests/repo/main.1101613.obb.main.twoversions.obb @@ -0,0 +1 @@ +dummy diff --git a/tests/repo/main.1101615.obb.main.twoversions.obb b/tests/repo/main.1101615.obb.main.twoversions.obb new file mode 100644 index 00000000..421376db --- /dev/null +++ b/tests/repo/main.1101615.obb.main.twoversions.obb @@ -0,0 +1 @@ +dummy diff --git a/tests/repo/main.1434483388.obb.main.oldversion.obb b/tests/repo/main.1434483388.obb.main.oldversion.obb new file mode 100644 index 00000000..421376db --- /dev/null +++ b/tests/repo/main.1434483388.obb.main.oldversion.obb @@ -0,0 +1 @@ +dummy diff --git a/tests/repo/main.1619.obb.mainpatch.current.obb b/tests/repo/main.1619.obb.mainpatch.current.obb new file mode 100644 index 00000000..421376db --- /dev/null +++ b/tests/repo/main.1619.obb.mainpatch.current.obb @@ -0,0 +1 @@ +dummy diff --git a/tests/repo/obb.main.oldversion_1444412523.apk b/tests/repo/obb.main.oldversion_1444412523.apk new file mode 100644 index 00000000..94ed9503 Binary files /dev/null and b/tests/repo/obb.main.oldversion_1444412523.apk differ diff --git a/tests/repo/obb.main.twoversions_1101613.apk b/tests/repo/obb.main.twoversions_1101613.apk new file mode 100644 index 00000000..259d0903 Binary files /dev/null and b/tests/repo/obb.main.twoversions_1101613.apk differ diff --git a/tests/repo/obb.main.twoversions_1101615.apk b/tests/repo/obb.main.twoversions_1101615.apk new file mode 100644 index 00000000..0d82052e Binary files /dev/null and b/tests/repo/obb.main.twoversions_1101615.apk differ diff --git a/tests/repo/obb.main.twoversions_1101617.apk b/tests/repo/obb.main.twoversions_1101617.apk new file mode 100644 index 00000000..202d6a03 Binary files /dev/null and b/tests/repo/obb.main.twoversions_1101617.apk differ diff --git a/tests/repo/obb.mainpatch.current_1619.apk b/tests/repo/obb.mainpatch.current_1619.apk new file mode 100644 index 00000000..23cf8232 Binary files /dev/null and b/tests/repo/obb.mainpatch.current_1619.apk differ diff --git a/tests/repo/patch.1619.obb.mainpatch.current.obb b/tests/repo/patch.1619.obb.mainpatch.current.obb new file mode 100644 index 00000000..421376db --- /dev/null +++ b/tests/repo/patch.1619.obb.mainpatch.current.obb @@ -0,0 +1 @@ +dummy diff --git a/tests/update.TestCase b/tests/update.TestCase index 1005a158..e2927932 100755 --- a/tests/update.TestCase +++ b/tests/update.TestCase @@ -83,7 +83,7 @@ class UpdateTest(unittest.TestCase): pysig = fdroidserver.update.getsig(apkfile) self.assertIsNone(pysig, "python sig should be None: " + str(sig)) - def testScanApks(self): + def testScanApksAndObbs(self): os.chdir(os.path.dirname(__file__)) if os.path.basename(os.getcwd()) != 'tests': raise Exception('This test must be run in the "tests/" subdir') @@ -97,18 +97,39 @@ class UpdateTest(unittest.TestCase): fdroidserver.update.options = type('', (), {})() fdroidserver.update.options.clean = True + fdroidserver.update.options.delete_unknown = True - alltestapps = fdroidserver.metadata.read_metadata(xref=True) - apps = dict() - apps['info.guardianproject.urzip'] = alltestapps['info.guardianproject.urzip'] + apps = fdroidserver.metadata.read_metadata(xref=True) knownapks = fdroidserver.common.KnownApks() apks, cachechanged = fdroidserver.update.scan_apks(apps, {}, 'repo', knownapks, False) - self.assertEqual(len(apks), 1) + self.assertEqual(len(apks), 6) apk = apks[0] self.assertEqual(apk['minSdkVersion'], '4') self.assertEqual(apk['targetSdkVersion'], '18') self.assertFalse('maxSdkVersion' in apk) + fdroidserver.update.insert_obbs('repo', apps, apks) + for apk in apks: + if apk['id'] == 'obb.mainpatch.current': + self.assertEqual(apk.get('obbMainFile'), 'main.1619.obb.mainpatch.current.obb') + self.assertEqual(apk.get('obbPatchFile'), 'patch.1619.obb.mainpatch.current.obb') + elif apk['id'] == 'obb.main.oldversion': + self.assertEqual(apk.get('obbMainFile'), 'main.1434483388.obb.main.oldversion.obb') + self.assertIsNone(apk.get('obbPatchFile')) + elif apk['id'] == 'obb.main.twoversions': + self.assertIsNone(apk.get('obbPatchFile')) + if apk['versioncode'] == 1101613: + self.assertEqual(apk.get('obbMainFile'), 'main.1101613.obb.main.twoversions.obb') + elif apk['versioncode'] == 1101615: + self.assertEqual(apk.get('obbMainFile'), 'main.1101615.obb.main.twoversions.obb') + elif apk['versioncode'] == 1101617: + self.assertEqual(apk.get('obbMainFile'), 'main.1101615.obb.main.twoversions.obb') + else: + self.assertTrue(False) + elif apk['id'] == 'info.guardianproject.urzip': + self.assertIsNone(apk.get('obbMainFile')) + self.assertIsNone(apk.get('obbPatchFile')) + if __name__ == "__main__": parser = optparse.OptionParser()