2 # -*- coding: utf-8 -*-
4 # http://www.drdobbs.com/testing/unit-testing-with-python/240165163
12 localmodule = os.path.realpath(os.path.join(
13 os.path.dirname(inspect.getfile(inspect.currentframe())),
15 print('localmodule: ' + localmodule)
16 if localmodule not in sys.path:
17 sys.path.insert(0,localmodule)
19 import fdroidserver.common
21 class CommonTest(unittest.TestCase):
22 '''fdroidserver/common.py'''
24 def testIsApkDebuggable(self):
26 config['aapt'] = '/usr/bin/aapt'
27 # these are set debuggable
29 testfiles.append(os.path.join(os.path.dirname(__file__), 'urzip.apk'))
30 testfiles.append(os.path.join(os.path.dirname(__file__), 'urzip-badsig.apk'))
31 testfiles.append(os.path.join(os.path.dirname(__file__), 'urzip-badcert.apk'))
32 for apkfile in testfiles:
33 debuggable = fdroidserver.common.isApkDebuggable(apkfile, config)
34 self.assertTrue(debuggable,
35 "debuggable APK state was not properly parsed!")
36 # these are set NOT debuggable
38 testfiles.append(os.path.join(os.path.dirname(__file__), 'urzip-release.apk'))
39 testfiles.append(os.path.join(os.path.dirname(__file__), 'urzip-release-unsigned.apk'))
40 for apkfile in testfiles:
41 debuggable = fdroidserver.common.isApkDebuggable(apkfile, config)
42 self.assertFalse(debuggable,
43 "debuggable APK state was not properly parsed!")
46 if __name__ == "__main__":
47 parser = optparse.OptionParser()
48 parser.add_option("-v", "--verbose", action="store_true", default=False,
49 help="Spew out even more information than normal")
50 (fdroidserver.common.options, args) = parser.parse_args(['--verbose'])
52 newSuite = unittest.TestSuite()
53 newSuite.addTest(unittest.makeSuite(CommonTest))