mirror of
https://gitlab.com/fdroid/fdroidserver.git
synced 2024-11-20 13:50:12 +01:00
3768d7a4d6
The start up sequence of processes that are based on the .fdroid.* metadata is a bit different, so this ensures that the environment variables get properly initialized in all cases. This also creates a single function where the environment is set. Before it was being set in multiple places across multiple files.
47 lines
1.5 KiB
Python
Executable File
47 lines
1.5 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
|
|
# http://www.drdobbs.com/testing/unit-testing-with-python/240165163
|
|
|
|
import inspect
|
|
import optparse
|
|
import os
|
|
import sys
|
|
import unittest
|
|
|
|
localmodule = os.path.realpath(
|
|
os.path.join(os.path.dirname(inspect.getfile(inspect.currentframe())), '..'))
|
|
print('localmodule: ' + localmodule)
|
|
if localmodule not in sys.path:
|
|
sys.path.insert(0, localmodule)
|
|
|
|
import fdroidserver.common
|
|
import fdroidserver.install
|
|
|
|
|
|
class InstallTest(unittest.TestCase):
|
|
'''fdroidserver/install.py'''
|
|
|
|
def test_devices(self):
|
|
config = dict()
|
|
fdroidserver.common.fill_config_defaults(config)
|
|
fdroidserver.common.config = config
|
|
config['adb'] = fdroidserver.common.find_sdk_tools_cmd('adb')
|
|
self.assertTrue(os.path.exists(config['adb']))
|
|
self.assertTrue(os.path.isfile(config['adb']))
|
|
devices = fdroidserver.install.devices()
|
|
self.assertIsInstance(devices, list, 'install.devices() did not return a list!')
|
|
for device in devices:
|
|
self.assertIsInstance(device, str)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
parser = optparse.OptionParser()
|
|
parser.add_option("-v", "--verbose", action="store_true", default=False,
|
|
help="Spew out even more information than normal")
|
|
(fdroidserver.install.options, args) = parser.parse_args(['--verbose'])
|
|
fdroidserver.common.options = fdroidserver.install.options
|
|
|
|
newSuite = unittest.TestSuite()
|
|
newSuite.addTest(unittest.makeSuite(InstallTest))
|
|
unittest.main()
|