diff options
author | Szczepan Zalega <szczepan@nitrokey.com> | 2018-03-02 11:41:13 +0100 |
---|---|---|
committer | Szczepan Zalega <szczepan@nitrokey.com> | 2018-03-02 11:41:13 +0100 |
commit | 379daf936caa7fc8d7311a5dda101edb40d35ca5 (patch) | |
tree | 2d186dec6976b12a9f7b37e589c02703275a30ef /unittest/test_multiple.py | |
parent | d5486ba77235a874245fbee07a75cea89fa59ea2 (diff) | |
parent | c3d615b659b608f3a1d624f6fc78c303efbe1f8e (diff) | |
download | libnitrokey-379daf936caa7fc8d7311a5dda101edb40d35ca5.tar.gz libnitrokey-379daf936caa7fc8d7311a5dda101edb40d35ca5.tar.bz2 |
Merge branch 'wip-multiple_devices'
Allow to use multiple devices, iteratively.
Storage only.
Diffstat (limited to 'unittest/test_multiple.py')
-rw-r--r-- | unittest/test_multiple.py | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/unittest/test_multiple.py b/unittest/test_multiple.py new file mode 100644 index 0000000..7ea195e --- /dev/null +++ b/unittest/test_multiple.py @@ -0,0 +1,60 @@ +import pprint +from time import sleep + +import pytest +from collections import defaultdict + +from tqdm import tqdm + +from conftest import skip_if_device_version_lower_than +from constants import DefaultPasswords, DeviceErrorCode, bb +from misc import gs, wait + +pprint = pprint.PrettyPrinter(indent=4).pprint + + +@pytest.mark.other +@pytest.mark.info +def test_get_status_storage_multiple(C): + ids = gs(C.NK_list_devices_by_cpuID()) + print(ids) + devices_list = ids.split(b';') + # + # for s in devices_list: + # res = C.NK_connect_with_ID(s) + # assert res == 1 + # # st = gs(C.NK_get_status_storage_as_string()) + # # print(len(st)) + # C.NK_lock_device() + # + for s in devices_list: + res = C.NK_connect_with_ID(s) + assert res == 1 + v = C.NK_fill_SD_card_with_random_data(b'12345678') + # print(v) + + devices_count = len(devices_list) + assert devices_count != 0 + b = 0 + + last_b = 0 + with tqdm(total=devices_count*100) as pbar: + while b/devices_count < 100: + pbar.update(b - last_b) + + b = defaultdict (lambda: 0) + + ids = gs(C.NK_list_devices_by_cpuID()) + devices_list = ids.split(b';') + devices_count = len(devices_list) + + for s in devices_list: + res = C.NK_connect_with_ID(s) + if res != 1: continue + b[s] += C.NK_get_progress_bar_value() + print(b) + b = sum(b.values()) + print('{}: {}'.format(b, int(b/devices_count) * '=')) + sleep(5) + + |