diff --git a/lib/logitech/unifying_receiver/tests/__init__.py b/lib/logitech/unifying_receiver/tests/__init__.py deleted file mode 100644 index 7c4bc79e..00000000 --- a/lib/logitech/unifying_receiver/tests/__init__.py +++ /dev/null @@ -1,3 +0,0 @@ -# -# Tests for the logitech.unifying_receiver package. -# diff --git a/lib/logitech/unifying_receiver/tests/test_10_constants.py b/lib/logitech/unifying_receiver/tests/test_10_constants.py deleted file mode 100644 index 57f7e34c..00000000 --- a/lib/logitech/unifying_receiver/tests/test_10_constants.py +++ /dev/null @@ -1,33 +0,0 @@ -# -# -# - -import unittest -import struct - -from ..constants import * - - -class Test_UR_Constants(unittest.TestCase): - - def test_10_feature_names(self): - for code in range(0x0000, 0x10000): - feature = struct.pack('!H', code) - name = FEATURE_NAME[feature] - self.assertIsNotNone(name) - self.assertEqual(FEATURE_NAME[code], name) - if name.startswith('UNKNOWN_'): - self.assertEqual(code, struct.unpack('!H', feature)[0]) - else: - self.assertTrue(hasattr(FEATURE, name)) - self.assertEqual(feature, getattr(FEATURE, name)) - - def test_20_error_names(self): - for code in range(0, len(ERROR_NAME)): - name = ERROR_NAME[code] - self.assertIsNotNone(name) - # self.assertEqual(code, ERROR_NAME.index(name)) - - -if __name__ == '__main__': - unittest.main() diff --git a/lib/logitech/unifying_receiver/tests/test_30_base.py b/lib/logitech/unifying_receiver/tests/test_30_base.py deleted file mode 100644 index f7902e42..00000000 --- a/lib/logitech/unifying_receiver/tests/test_30_base.py +++ /dev/null @@ -1,187 +0,0 @@ -# -# -# - -import unittest - -from .. import base -from ..exceptions import * -from ..constants import * - - -class Test_UR_Base(unittest.TestCase): - @classmethod - def setUpClass(cls): - cls.ur_available = False - cls.handle = None - cls.device = None - - @classmethod - def tearDownClass(cls): - if cls.handle: - base.close(cls.handle) - cls.ur_available = False - cls.handle = None - cls.device = None - - def test_10_list_receiver_devices(self): - rawdevices = base.list_receiver_devices() - self.assertIsNotNone(rawdevices, "list_receiver_devices returned None") - # self.assertIsInstance(rawdevices, Iterable, "list_receiver_devices should have returned an iterable") - Test_UR_Base.ur_available = len(list(rawdevices)) > 0 - - def test_20_open_path(self): - if not self.ur_available: - self.fail("No receiver found") - - for rawdevice in base.list_receiver_devices(): - handle = base.open_path(rawdevice.path) - if handle is None: - continue - - self.assertIsInstance(handle, int, "open_path should have returned an int") - - if Test_UR_Base.handle is None: - Test_UR_Base.handle = handle - else: - base.close(handle) - base.close(Test_UR_Base.handle) - Test_UR_Base.handle = None - self.fail("try_open found multiple valid receiver handles") - - self.assertIsNotNone(self.handle, "no valid receiver handles found") - - def test_25_ping_device_zero(self): - if self.handle is None: - self.fail("No receiver found") - - w = base.write(self.handle, 0, b'\x00\x10\x00\x00\xAA') - self.assertIsNone(w, "write should have returned None") - reply = base.read(self.handle, base.DEFAULT_TIMEOUT * 3) - self.assertIsNotNone(reply, "None reply for ping") - self.assertIsInstance(reply, tuple, "read should have returned a tuple") - - reply_code, reply_device, reply_data = reply - self.assertEqual(reply_device, 0, "got ping reply for valid device") - self.assertGreater(len(reply_data), 4, "ping reply has wrong length: %s" % base._hex(reply_data)) - if reply_code == 0x10: - # ping fail - self.assertEqual(reply_data[:3], b'\x8F\x00\x10', "0x10 reply with unknown reply data: %s" % base._hex(reply_data)) - elif reply_code == 0x11: - self.fail("Got valid ping from device 0") - else: - self.fail("ping got bad reply code: " + reply) - - def test_30_ping_all_devices(self): - if self.handle is None: - self.fail("No receiver found") - - devices = [] - - for device in range(1, 1 + MAX_ATTACHED_DEVICES): - w = base.write(self.handle, device, b'\x00\x10\x00\x00\xAA') - self.assertIsNone(w, "write should have returned None") - reply = base.read(self.handle, base.DEFAULT_TIMEOUT * 3) - self.assertIsNotNone(reply, "None reply for ping") - self.assertIsInstance(reply, tuple, "read should have returned a tuple") - - reply_code, reply_device, reply_data = reply - self.assertEqual(reply_device, device, "ping reply for wrong device") - self.assertGreater(len(reply_data), 4, "ping reply has wrong length: %s" % base._hex(reply_data)) - if reply_code == 0x10: - # ping fail - self.assertEqual(reply_data[:3], b'\x8F\x00\x10', "0x10 reply with unknown reply data: %s" % base._hex(reply_data)) - elif reply_code == 0x11: - # ping ok - self.assertEqual(reply_data[:2], b'\x00\x10', "0x11 reply with unknown reply data: %s" % base._hex(reply_data)) - self.assertEqual(reply_data[4:5], b'\xAA') - devices.append(device) - else: - self.fail("ping got bad reply code: " + reply) - - if devices: - Test_UR_Base.device = devices[0] - - def test_50_request_bad_device(self): - if self.handle is None: - self.fail("No receiver found") - - device = 1 if self.device is None else self.device + 1 - reply = base.request(self.handle, device, FEATURE.ROOT, FEATURE.FEATURE_SET) - self.assertIsNone(reply, "request returned valid reply") - - def test_52_request_root_no_feature(self): - if self.handle is None: - self.fail("No receiver found") - if self.device is None: - self.fail("No devices attached") - - reply = base.request(self.handle, self.device, FEATURE.ROOT) - self.assertIsNotNone(reply, "request returned None reply") - self.assertEqual(reply[:2], b'\x00\x00', "request returned for wrong feature id") - - def test_55_request_root_feature_set(self): - if self.handle is None: - self.fail("No receiver found") - if self.device is None: - self.fail("No devices attached") - - reply = base.request(self.handle, self.device, FEATURE.ROOT, FEATURE.FEATURE_SET) - self.assertIsNotNone(reply, "request returned None reply") - index = reply[:1] - self.assertGreater(index, b'\x00', "FEATURE_SET not available on device " + str(self.device)) - - # def test_57_request_ignore_undhandled(self): - # if self.handle is None: - # self.fail("No receiver found") - # if self.device is None: - # self.fail("No devices attached") - - # fs_index = base.request(self.handle, self.device, FEATURE.ROOT, FEATURE.FEATURE_SET) - # self.assertIsNotNone(fs_index) - # fs_index = fs_index[:1] - # self.assertGreater(fs_index, b'\x00') - - # global received_unhandled - # received_unhandled = None - - # def _unhandled(code, device, data): - # self.assertIsNotNone(code) - # self.assertIsInstance(code, int) - # self.assertIsNotNone(device) - # self.assertIsInstance(device, int) - # self.assertIsNotNone(data) - # self.assertIsInstance(data, str) - # global received_unhandled - # received_unhandled = (code, device, data) - - # base.unhandled_hook = _unhandled - # base.write(self.handle, self.device, FEATURE.ROOT + FEATURE.FEATURE_SET) - # reply = base.request(self.handle, self.device, fs_index + b'\x00') - # self.assertIsNotNone(reply, "request returned None reply") - # self.assertNotEquals(reply[:1], b'\x00') - # self.assertIsNotNone(received_unhandled, "extra message not received by unhandled hook") - - # received_unhandled = None - # base.unhandled_hook = None - # base.write(self.handle, self.device, FEATURE.ROOT + FEATURE.FEATURE_SET) - # reply = base.request(self.handle, self.device, fs_index + b'\x00') - # self.assertIsNotNone(reply, "request returned None reply") - # self.assertNotEquals(reply[:1], b'\x00') - # self.assertIsNone(received_unhandled) - - # del received_unhandled - - # def test_90_receiver_missing(self): - # if self.handle is None: - # self.fail("No receiver found") - # - # logging.warn("remove the receiver in 5 seconds or this test will fail") - # import time - # time.sleep(5) - # with self.assertRaises(NoReceiver): - # self.test_30_ping_all_devices() - - -if __name__ == '__main__': - unittest.main() diff --git a/lib/logitech/unifying_receiver/tests/test_50_api.py b/lib/logitech/unifying_receiver/tests/test_50_api.py deleted file mode 100644 index 8ef6700a..00000000 --- a/lib/logitech/unifying_receiver/tests/test_50_api.py +++ /dev/null @@ -1,128 +0,0 @@ -# -# -# - -import unittest -import warnings - -from .. import api -from ..constants import * -from ..common import * - - -class Test_UR_API(unittest.TestCase): - @classmethod - def setUpClass(cls): - cls.receiver = None - cls.device = None - cls.features = None - cls.device_info = None - - @classmethod - def tearDownClass(cls): - if cls.receiver: - cls.receiver.close() - cls.device = None - cls.features = None - cls.device_info = None - - def _check(self, check_device=True, check_features=False): - if self.receiver is None: - self.fail("No receiver found") - if check_device and self.device is None: - self.fail("Found no devices attached.") - if check_device and check_features and self.features is None: - self.fail("no feature set available") - - def test_00_open_receiver(self): - Test_UR_API.receiver = api.Receiver.open() - self._check(check_device=False) - - def test_10_ping_all_devices(self): - self._check(check_device=False) - - devices = [] - - for devnumber in range(1, 1 + MAX_ATTACHED_DEVICES): - d = api.PairedDevice(self.receiver.handle, devnumber) - ok = d.ping() - self.assertIsNotNone(ok, "invalid ping reply") - if ok: - devices.append(self.receiver[devnumber]) - - if devices: - Test_UR_API.device = devices[0].number - - def test_30_get_feature_index(self): - self._check() - - fs_index = api.get_feature_index(self.receiver.handle, self.device, FEATURE.FEATURE_SET) - self.assertIsNotNone(fs_index, "feature FEATURE_SET not available") - self.assertGreater(fs_index, 0, "invalid FEATURE_SET index: " + str(fs_index)) - - def test_31_bad_feature(self): - self._check() - - reply = api.request(self.receiver.handle, self.device, FEATURE.ROOT, params=b'\xFF\xFF') - self.assertIsNotNone(reply, "invalid reply") - self.assertEqual(reply[:5], b'\x00' * 5, "invalid reply") - - def test_40_get_device_features(self): - self._check() - - features = api.get_device_features(self.receiver.handle, self.device) - self.assertIsNotNone(features, "failed to read features array") - self.assertIn(FEATURE.FEATURE_SET, features, "feature FEATURE_SET not available") - # cache this to simplify next tests - Test_UR_API.features = features - - def test_50_get_device_firmware(self): - self._check(check_features=True) - - d_firmware = api.get_device_firmware(self.receiver.handle, self.device, self.features) - self.assertIsNotNone(d_firmware, "failed to get device firmware") - self.assertGreater(len(d_firmware), 0, "device reported no firmware") - for fw in d_firmware: - self.assertIsInstance(fw, FirmwareInfo) - - def test_52_get_device_kind(self): - self._check(check_features=True) - - d_kind = api.get_device_kind(self.receiver.handle, self.device, self.features) - self.assertIsNotNone(d_kind, "failed to get device kind") - self.assertGreater(len(d_kind), 0, "empty device kind") - - def test_55_get_device_name(self): - self._check(check_features=True) - - d_name = api.get_device_name(self.receiver.handle, self.device, self.features) - self.assertIsNotNone(d_name, "failed to read device name") - self.assertGreater(len(d_name), 0, "empty device name") - - def test_59_get_device_info(self): - self._check(check_features=True) - - device_info = api.get_device(self.receiver.handle, self.device, features=self.features) - self.assertIsNotNone(device_info, "failed to read full device info") - self.assertIsInstance(device_info, api.PairedDevice) - Test_UR_API.device_info = device_info - - def test_60_get_battery_level(self): - self._check(check_features=True) - - if FEATURE.BATTERY in self.features: - battery = api.get_device_battery_level(self.receiver.handle, self.device, self.features) - self.assertIsNotNone(battery, "failed to read battery level") - self.assertIsInstance(battery, tuple, "result not a tuple") - else: - warnings.warn("BATTERY feature not supported by device %d" % self.device) - - def test_70_list_devices(self): - self._check(check_device=False) - - for dev in self.receiver: - self.assertIsNotNone(dev) - self.assertIsInstance(dev, api.PairedDevice) - -if __name__ == '__main__': - unittest.main() diff --git a/lib/unittest.sh b/lib/unittest.sh deleted file mode 100755 index 84cf75f8..00000000 --- a/lib/unittest.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh - -cd -P `dirname "$0"` - -export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$PWD/native/`uname -m` - -exec python -m unittest discover -v "$@"