commit 93da32b7466af86395eb556eea74012d2c474304
Author: silhavyj <jakub.sil@seznam.cz>
Date:   Tue Apr 5 08:54:23 2022 +0200

    re #9421 Added unit tests for get_connected_devices() and get_disconnected_devices()

diff --git a/client/src/usb_detector/detector.py b/client/src/usb_detector/detector.py
index 7f7f34e..8804bc9 100644
--- a/client/src/usb_detector/detector.py
+++ b/client/src/usb_detector/detector.py
@@ -49,10 +49,18 @@ def _load_last_connected_devices() -> list:
 
 
 def _get_connected_devices(detected_devices: list, last_connected_devices: list) -> list:
+    if last_connected_devices is None and detected_devices is not None:
+        return detected_devices
+    if detected_devices is None:
+        return []
     return [device for device in detected_devices if device not in last_connected_devices]
 
 
 def _get_disconnected_devices(detected_devices: list, last_connected_devices: list) -> list:
+    if last_connected_devices is None:
+        return []
+    if detected_devices is None:
+        return last_connected_devices
     return [device for device in last_connected_devices if device not in detected_devices]
 
 
diff --git a/client/tests/README.md b/client/tests/README.md
deleted file mode 100644
index df59d54..0000000
--- a/client/tests/README.md
+++ /dev/null
@@ -1 +0,0 @@
-## Tests go gere
\ No newline at end of file
diff --git a/client/tests/detector/test_get_connected_devices.py b/client/tests/detector/test_get_connected_devices.py
new file mode 100644
index 0000000..ec17fcb
--- /dev/null
+++ b/client/tests/detector/test_get_connected_devices.py
@@ -0,0 +1,62 @@
+from client.src.usb_detector import detector
+
+
+def test_get_connected_devices_1():
+    assert detector._get_connected_devices([], []) == []
+
+
+def test_get_connected_devices_2():
+    assert detector._get_connected_devices([], None) == []
+
+
+def test_get_connected_devices_3():
+    assert detector._get_connected_devices(None, []) == []
+
+
+def test_get_connected_devices_4():
+    assert detector._get_connected_devices(None, None) == []
+
+
+def test_get_connected_devices_5():
+    assert detector._get_connected_devices([1, 2, 3], None) == [1, 2, 3]
+
+
+def test_get_connected_devices_6():
+    assert detector._get_connected_devices(None, [4, 5, 6]) == []
+
+
+def test_get_connected_devices_7():
+    assert detector._get_connected_devices([], [4, 5, 6]) == []
+
+
+def test_get_connected_devices_8():
+    assert detector._get_connected_devices([1, 2, 3], []) == [1, 2, 3]
+
+
+def test_get_connected_devices_9():
+    assert detector._get_connected_devices([1, 2, 3], [2, 3]) == [1]
+
+
+def test_get_connected_devices_10():
+    detected_devices = [
+        {
+            "vendor_id": 1,
+            "product_id": 2,
+            "serial_number": 3
+        },
+        {
+            "vendor_id": 4,
+            "product_id": 5,
+            "serial_number": 5
+        }
+    ]
+    last_connected_devices = [
+        {
+            "vendor_id": 1,
+            "product_id": 2,
+            "serial_number": 3
+        }
+    ]
+    assert detector._get_connected_devices(detected_devices, last_connected_devices) == [detected_devices[1]]
+    assert detector._get_connected_devices(detected_devices, None) == detected_devices
+    assert detector._get_connected_devices(detected_devices, []) == detected_devices
diff --git a/client/tests/detector/test_get_disconnected_devices.py b/client/tests/detector/test_get_disconnected_devices.py
new file mode 100644
index 0000000..1f998d7
--- /dev/null
+++ b/client/tests/detector/test_get_disconnected_devices.py
@@ -0,0 +1,66 @@
+from client.src.usb_detector import detector
+
+
+def test_get_disconnected_devices_1():
+    assert detector._get_disconnected_devices([], []) == []
+
+
+def test_get_disconnected_devices_2():
+    assert detector._get_disconnected_devices([], None) == []
+
+
+def test_get_disconnected_devices_3():
+    assert detector._get_disconnected_devices(None, []) == []
+
+
+def test_get_disconnected_devices_4():
+    assert detector._get_disconnected_devices(None, None) == []
+
+
+def test_get_disconnected_devices_5():
+    assert detector._get_disconnected_devices([1, 2, 3, 4, 5], None) == []
+
+
+def test_get_disconnected_devices_6():
+    assert detector._get_disconnected_devices([1, 2, 3, 4, 5], []) == []
+
+
+def test_get_disconnected_devices_7():
+    assert detector._get_disconnected_devices([1, 3, 5], [1, 2, 3, 4, 5]) == [2, 4]
+
+
+def test_get_disconnected_devices_8():
+    assert detector._get_disconnected_devices([], [1, 2, 3, 4, 5]) == [1, 2, 3, 4, 5]
+
+
+def test_get_disconnected_devices_9():
+    assert detector._get_disconnected_devices([], [1, 2, 3, 4, 5]) == [1, 2, 3, 4, 5]
+
+
+def test_get_disconnected_devices_10():
+    last_connected_devices = [
+        {
+            "vendor_id": 1,
+            "product_id": 2,
+            "serial_number": 3
+        },
+        {
+            "vendor_id": 4,
+            "product_id": 5,
+            "serial_number": 5
+        }
+    ]
+    detected_devices = [
+        {
+            "vendor_id": 1,
+            "product_id": 2,
+            "serial_number": 3
+        }
+    ]
+    assert detector._get_disconnected_devices(detected_devices, last_connected_devices) == [last_connected_devices[1]]
+    assert detector._get_disconnected_devices(detected_devices, None) == []
+    assert detector._get_disconnected_devices(detected_devices, []) == []
+    assert detector._get_disconnected_devices([], last_connected_devices) == last_connected_devices
+    assert detector._get_disconnected_devices(None, last_connected_devices) == last_connected_devices
+
+
