3 # http://www.drdobbs.com/testing/unit-testing-with-python/240165163
13 localmodule = os.path.realpath(
14 os.path.join(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
20 import fdroidserver.metadata
21 # work around the syntax error from: import fdroidserver.import
25 class ImportTest(unittest.TestCase):
29 logging.basicConfig(level=logging.DEBUG)
30 self.basedir = os.path.join(localmodule, 'tests')
31 self.tmpdir = os.path.abspath(os.path.join(self.basedir, '..', '.testfiles'))
32 if not os.path.exists(self.tmpdir):
33 os.makedirs(self.tmpdir)
34 os.chdir(self.basedir)
36 def test_import_gitlab(self):
37 # FDroidPopen needs some config to work
39 fdroidserver.common.fill_config_defaults(config)
40 fdroidserver.common.config = config
42 url = 'https://gitlab.com/fdroid/ci-test-app'
43 r = requests.head(url)
44 if r.status_code != 200:
45 print("ERROR", url, 'unreachable (', r.status_code, ')')
46 print('Skipping ImportTest!')
49 app = fdroidserver.metadata.App()
50 app.UpdateCheckMode = "Tags"
51 root_dir, src_dir = import_proxy.get_metadata_from_url(app, url)
52 self.assertEqual(app.RepoType, 'git')
53 self.assertEqual(app.WebSite, 'https://gitlab.com/fdroid/ci-test-app')
54 self.assertEqual(app.Repo, 'https://gitlab.com/fdroid/ci-test-app.git')
57 if __name__ == "__main__":
58 parser = optparse.OptionParser()
59 parser.add_option("-v", "--verbose", action="store_true", default=False,
60 help="Spew out even more information than normal")
61 (fdroidserver.common.options, args) = parser.parse_args(['--verbose'])
63 newSuite = unittest.TestSuite()
64 newSuite.addTest(unittest.makeSuite(ImportTest))
65 unittest.main(failfast=False)