10 localmodule = os.path.realpath(
11 os.path.join(os.path.dirname(inspect.getfile(inspect.currentframe())), '..'))
12 print('localmodule: ' + localmodule)
13 if localmodule not in sys.path:
14 sys.path.insert(0, localmodule)
16 import fdroidserver.common
17 import fdroidserver.metadata
18 import fdroidserver.update
21 class UpdateTest(unittest.TestCase):
22 '''fdroid androguard manual tests'''
24 def testScanMetadataAndroguardAAPT(self):
26 def _create_apkmetadata_object(apkName):
27 '''Create an empty apk metadata object'''
29 apk['apkName'] = apkName
30 apk['uses-permission'] = []
31 apk['uses-permission-sdk-23'] = []
37 fdroidserver.common.fill_config_defaults(config)
38 fdroidserver.update.config = config
39 os.chdir(os.path.dirname(__file__))
40 if os.path.basename(os.getcwd()) != 'tests':
41 raise Exception('This test must be run in the "tests/" subdir')
43 config['ndk_paths'] = dict()
44 config['accepted_formats'] = ['json', 'txt', 'yml']
45 fdroidserver.common.config = config
46 fdroidserver.update.config = config
48 fdroidserver.update.options = type('', (), {})()
49 fdroidserver.update.options.clean = True
50 fdroidserver.update.options.delete_unknown = True
52 self.assertTrue(fdroidserver.common.SdkToolsPopen('aapt'))
54 from androguard.core.bytecodes.apk import APK
57 raise Exception("androguard not installed!")
59 apkList = ['../info.guardianproject.urzip.apk', '../org.dyndns.fules.ck_20.apk']
61 for apkName in apkList:
62 logging.debug("Processing " + apkName)
63 apkfile = os.path.join('repo', apkName)
65 apkaapt = _create_apkmetadata_object(apkName)
66 logging.debug("Using AAPT for metadata")
67 fdroidserver.update.scan_apk_aapt(apkaapt, apkfile)
68 # avoid AAPT application name bug
71 apkandroguard = _create_apkmetadata_object(apkName)
72 logging.debug("Using androguard for metadata")
73 fdroidserver.update.scan_apk_androguard(apkandroguard, apkfile)
74 # avoid AAPT application name bug
75 del apkandroguard['name']
78 self.assertEqual(apkaapt, apkandroguard)
81 if __name__ == "__main__":
82 parser = optparse.OptionParser()
83 parser.add_option("-v", "--verbose", action="store_true", default=False,
84 help="Spew out even more information than normal")
85 (fdroidserver.common.options, args) = parser.parse_args(['--verbose'])
87 newSuite = unittest.TestSuite()
88 newSuite.addTest(unittest.makeSuite(UpdateTest))