chiark / gitweb /
Replace deprecated mwclient method
[fdroidserver.git] / tests / install.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 sys
9 import unittest
10
11 localmodule = os.path.realpath(
12     os.path.join(os.path.dirname(inspect.getfile(inspect.currentframe())), '..'))
13 print('localmodule: ' + localmodule)
14 if localmodule not in sys.path:
15     sys.path.insert(0, localmodule)
16
17 import fdroidserver.common
18 import fdroidserver.install
19
20
21 class InstallTest(unittest.TestCase):
22     '''fdroidserver/install.py'''
23
24     def test_devices(self):
25         config = dict()
26         fdroidserver.common.fill_config_defaults(config)
27         fdroidserver.common.config = config
28         config['adb'] = fdroidserver.common.find_sdk_tools_cmd('adb')
29         self.assertTrue(os.path.exists(config['adb']))
30         self.assertTrue(os.path.isfile(config['adb']))
31         devices = fdroidserver.install.devices()
32         self.assertIsInstance(devices, list, 'install.devices() did not return a list!')
33         for device in devices:
34             self.assertIsInstance(device, str)
35
36
37 if __name__ == "__main__":
38     parser = optparse.OptionParser()
39     parser.add_option("-v", "--verbose", action="store_true", default=False,
40                       help="Spew out even more information than normal")
41     (fdroidserver.install.options, args) = parser.parse_args(['--verbose'])
42     fdroidserver.common.options = fdroidserver.install.options
43
44     newSuite = unittest.TestSuite()
45     newSuite.addTest(unittest.makeSuite(InstallTest))
46     unittest.main(failfast=False)