From da8bb27b8465acfc375769da8b3aecd5a92300a0 Mon Sep 17 00:00:00 2001
From: A_D <aunderscored@gmail.com>
Date: Tue, 10 Aug 2021 15:23:55 +0200
Subject: [PATCH] added deep get tests

---
 tests/killswitch.py/test_apply.py | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/tests/killswitch.py/test_apply.py b/tests/killswitch.py/test_apply.py
index bd7bdfd3..21f8c2cc 100644
--- a/tests/killswitch.py/test_apply.py
+++ b/tests/killswitch.py/test_apply.py
@@ -56,3 +56,23 @@ def test_apply_no_error() -> None:
 def test_get_int(input: str, expected: Optional[int]) -> None:
     """Check that _get_int doesn't throw when handed bad data."""
     assert expected == killswitch._get_int(input)
+
+
+@pytest.mark.parametrize(
+    ("source", "key", "action", "to_set", "result"),
+    [
+        (["this", "is", "a", "test"], "1", "delete", None, ["this", "a", "test"]),
+        (["this", "is", "a", "test"], "1", "", None, ["this", None, "a", "test"]),
+        ({"now": "with", "a": "dict"}, "now", "delete", None, {"a": "dict"}),
+        ({"now": "with", "a": "dict"}, "now", "", None, {"now": None, "a": "dict"}),
+        ({"depth": {"is": "important"}}, "depth.is", "", "nonexistent", {"depth": {"is": "nonexistent"}}),
+        ([{"test": ["stuff"]}], "0.test.0", "", "things", [{"test": ["things"]}]),
+        (({"test": {"with": ["a", "tuple"]}},), "0.test.with.0", "delete", "", ({"test": {"with": ["tuple"]}},)),
+        ({"test": ["with a", {"set", "of", "stuff"}]}, "test.1", "delete", "", {"test": ["with a"]})
+    ],
+)
+def test_deep_get(source: UPDATABLE_DATA, key: str, action: str, to_set: Any, result: UPDATABLE_DATA) -> None:
+    """Test _deep_get behaves as expected."""
+    cpy = copy.deepcopy(source)
+    killswitch._deep_apply(target=cpy, path=key, to_set=to_set, delete=action == "delete")
+    assert cpy == result