aboutsummaryrefslogtreecommitdiff
path: root/unittest/test_multiple.py
diff options
context:
space:
mode:
authorSzczepan Zalega <szczepan@nitrokey.com>2019-01-15 16:02:31 +0100
committerSzczepan Zalega <szczepan@nitrokey.com>2019-01-15 16:02:31 +0100
commite853275784e48823be0f39f0855efbe85c0f905c (patch)
tree2b428a23bddbd87c08ee47351bc31768f54b63fe /unittest/test_multiple.py
parent3f3fdebbc795dc3805cd5be105ce994286598f16 (diff)
parentcd1cfdbfc4113186f80dbadf5eb76543b22e34bd (diff)
downloadlibnitrokey-e853275784e48823be0f39f0855efbe85c0f905c.tar.gz
libnitrokey-e853275784e48823be0f39f0855efbe85c0f905c.tar.bz2
Merge branch 'pr_138' into contributions
Improve support for multiple devices Fixes #138
Diffstat (limited to 'unittest/test_multiple.py')
-rw-r--r--unittest/test_multiple.py29
1 files changed, 28 insertions, 1 deletions
diff --git a/unittest/test_multiple.py b/unittest/test_multiple.py
index 3f1d2d5..821a3b7 100644
--- a/unittest/test_multiple.py
+++ b/unittest/test_multiple.py
@@ -29,13 +29,40 @@ from tqdm import tqdm
from conftest import skip_if_device_version_lower_than
from constants import DefaultPasswords, DeviceErrorCode, bb
-from misc import gs, wait
+from misc import gs, wait, ffi
pprint = pprint.PrettyPrinter(indent=4).pprint
@pytest.mark.other
@pytest.mark.info
+def test_list_devices(C):
+ infos = C.NK_list_devices()
+ assert infos != ffi.NULL
+ C.NK_free_device_info(infos)
+
+
+@pytest.mark.other
+@pytest.mark.info
+def test_connect_with_path(C):
+ ids = gs(C.NK_list_devices_by_cpuID())
+ # NK_list_devices_by_cpuID already opened the devices, so we have to close
+ # them before trying to reconnect
+ assert C.NK_logout() == 0
+
+ devices_list = ids.split(b';')
+ for value in devices_list:
+ parts = value.split(b'_p_')
+ assert len(parts) < 3
+ if len(parts) == 2:
+ path = parts[1]
+ else:
+ path = parts[0]
+ assert C.NK_connect_with_path(path) == 1
+
+
+@pytest.mark.other
+@pytest.mark.info
def test_get_status_storage_multiple(C):
ids = gs(C.NK_list_devices_by_cpuID())
print(ids)