3 # http://www.drdobbs.com/testing/unit-testing-with-python/240165163
12 localmodule = os.path.realpath(
13 os.path.join(os.path.dirname(inspect.getfile(inspect.currentframe())), '..'))
14 print('localmodule: ' + localmodule)
15 if localmodule not in sys.path:
16 sys.path.insert(0, localmodule)
18 import fdroidserver.common
19 import fdroidserver.metadata
20 # work around the syntax error from: import fdroidserver.import
24 class ImportTest(unittest.TestCase):
27 def test_import_gitlab(self):
28 os.chdir(os.path.dirname(__file__))
29 # FDroidPopen needs some config to work
31 fdroidserver.common.fill_config_defaults(config)
32 fdroidserver.common.config = config
34 url = 'https://gitlab.com/fdroid/ci-test-app'
35 r = requests.head(url)
36 if r.status_code != 200:
37 print("ERROR", url, 'unreachable (', r.status_code, ')')
38 print('Skipping ImportTest!')
41 app = fdroidserver.metadata.App()
42 app.UpdateCheckMode = "Tags"
43 root_dir, src_dir = import_proxy.get_metadata_from_url(app, url)
44 self.assertEqual(app.RepoType, 'git')
45 self.assertEqual(app.WebSite, 'https://gitlab.com/fdroid/ci-test-app')
46 self.assertEqual(app.Repo, 'https://gitlab.com/fdroid/ci-test-app.git')
49 if __name__ == "__main__":
50 parser = optparse.OptionParser()
51 parser.add_option("-v", "--verbose", action="store_true", default=False,
52 help="Spew out even more information than normal")
53 (fdroidserver.common.options, args) = parser.parse_args(['--verbose'])
55 newSuite = unittest.TestSuite()
56 newSuite.addTest(unittest.makeSuite(ImportTest))