2016-01-04 21:17:58 +01:00
|
|
|
#!/usr/bin/env python3
|
2014-12-09 15:15:36 +01:00
|
|
|
|
|
|
|
# http://www.drdobbs.com/testing/unit-testing-with-python/240165163
|
|
|
|
|
|
|
|
import inspect
|
|
|
|
import os
|
|
|
|
import sys
|
|
|
|
import unittest
|
|
|
|
|
2015-07-22 08:19:56 +02:00
|
|
|
localmodule = os.path.realpath(
|
2021-06-07 11:49:21 +02:00
|
|
|
os.path.join(os.path.dirname(inspect.getfile(inspect.currentframe())), '..')
|
|
|
|
)
|
2014-12-09 15:15:36 +01:00
|
|
|
print('localmodule: ' + localmodule)
|
|
|
|
if localmodule not in sys.path:
|
2015-07-22 08:19:56 +02:00
|
|
|
sys.path.insert(0, localmodule)
|
2014-12-09 15:15:36 +01:00
|
|
|
|
|
|
|
import fdroidserver.common
|
|
|
|
import fdroidserver.install
|
|
|
|
|
2015-07-22 08:19:56 +02:00
|
|
|
|
2014-12-09 15:15:36 +01:00
|
|
|
class InstallTest(unittest.TestCase):
|
|
|
|
'''fdroidserver/install.py'''
|
|
|
|
|
|
|
|
def test_devices(self):
|
|
|
|
config = dict()
|
2015-08-05 14:39:58 +02:00
|
|
|
fdroidserver.common.fill_config_defaults(config)
|
2014-12-09 15:15:36 +01:00
|
|
|
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:
|
2016-01-04 17:28:55 +01:00
|
|
|
self.assertIsInstance(device, str)
|
2014-12-09 15:15:36 +01:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
2018-08-14 10:34:13 +02:00
|
|
|
os.chdir(os.path.dirname(__file__))
|
|
|
|
|
2024-05-02 14:08:28 +02:00
|
|
|
import argparse
|
2024-05-08 16:26:46 +02:00
|
|
|
from testcommon import parse_args_for_test
|
2024-05-02 14:08:28 +02:00
|
|
|
|
|
|
|
parser = argparse.ArgumentParser()
|
|
|
|
parser.add_argument(
|
2021-06-07 11:49:21 +02:00
|
|
|
"-v",
|
|
|
|
"--verbose",
|
|
|
|
action="store_true",
|
|
|
|
default=False,
|
|
|
|
help="Spew out even more information than normal",
|
|
|
|
)
|
2024-05-08 16:26:46 +02:00
|
|
|
fdroidserver.install.options = parse_args_for_test(parser, sys.argv)
|
2014-12-09 15:15:36 +01:00
|
|
|
|
|
|
|
newSuite = unittest.TestSuite()
|
|
|
|
newSuite.addTest(unittest.makeSuite(InstallTest))
|
2017-10-20 11:51:59 +02:00
|
|
|
unittest.main(failfast=False)
|