chiark / gitweb /
tests for finding the proper OBB files for each APK
authorHans-Christoph Steiner <hans@eds.org>
Mon, 20 Jun 2016 11:41:30 +0000 (13:41 +0200)
committerHans-Christoph Steiner <hans@eds.org>
Thu, 7 Jul 2016 20:34:41 +0000 (22:34 +0200)
14 files changed:
tests/metadata/obb.main.oldversion.txt [new file with mode: 0644]
tests/metadata/obb.main.twoversions.txt [new file with mode: 0644]
tests/metadata/obb.mainpatch.current.txt [new file with mode: 0644]
tests/repo/main.1101613.obb.main.twoversions.obb [new file with mode: 0644]
tests/repo/main.1101615.obb.main.twoversions.obb [new file with mode: 0644]
tests/repo/main.1434483388.obb.main.oldversion.obb [new file with mode: 0644]
tests/repo/main.1619.obb.mainpatch.current.obb [new file with mode: 0644]
tests/repo/obb.main.oldversion_1444412523.apk [new file with mode: 0644]
tests/repo/obb.main.twoversions_1101613.apk [new file with mode: 0644]
tests/repo/obb.main.twoversions_1101615.apk [new file with mode: 0644]
tests/repo/obb.main.twoversions_1101617.apk [new file with mode: 0644]
tests/repo/obb.mainpatch.current_1619.apk [new file with mode: 0644]
tests/repo/patch.1619.obb.mainpatch.current.obb [new file with mode: 0644]
tests/update.TestCase

diff --git a/tests/metadata/obb.main.oldversion.txt b/tests/metadata/obb.main.oldversion.txt
new file mode 100644 (file)
index 0000000..56c4a9f
--- /dev/null
@@ -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 (file)
index 0000000..d06afa3
--- /dev/null
@@ -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 (file)
index 0000000..2f7571f
--- /dev/null
@@ -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 (file)
index 0000000..421376d
--- /dev/null
@@ -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 (file)
index 0000000..421376d
--- /dev/null
@@ -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 (file)
index 0000000..421376d
--- /dev/null
@@ -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 (file)
index 0000000..421376d
--- /dev/null
@@ -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 (file)
index 0000000..94ed950
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 (file)
index 0000000..259d090
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 (file)
index 0000000..0d82052
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 (file)
index 0000000..202d6a0
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 (file)
index 0000000..23cf823
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 (file)
index 0000000..421376d
--- /dev/null
@@ -0,0 +1 @@
+dummy
index 1005a1582608c138dd76078350890bc152a784bd..e29279326a96b19e60c3141b9d36e68294a73027 100755 (executable)
@@ -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()