chiark / gitweb /
build: log vcs tools version on every build attempt
[fdroidserver.git] / tests / import.TestCase
1 #!/usr/bin/env python3
2
3 # http://www.drdobbs.com/testing/unit-testing-with-python/240165163
4
5 import inspect
6 import optparse
7 import os
8 import requests
9 import sys
10 import unittest
11
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)
17
18 import fdroidserver.common
19 import fdroidserver.metadata
20 # work around the syntax error from: import fdroidserver.import
21 import import_proxy
22
23
24 class ImportTest(unittest.TestCase):
25     '''fdroid import'''
26
27     def test_import_gitlab(self):
28         os.chdir(os.path.dirname(__file__))
29         # FDroidPopen needs some config to work
30         config = dict()
31         fdroidserver.common.fill_config_defaults(config)
32         fdroidserver.common.config = config
33
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!')
39             return
40
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')
47
48
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'])
54
55     newSuite = unittest.TestSuite()
56     newSuite.addTest(unittest.makeSuite(ImportTest))
57     unittest.main(failfast=False)