From 6da4df029a46af7717757941206f270118f643a8 Mon Sep 17 00:00:00 2001
From: Eva Bardou <ebardou@teklia.com>
Date: Wed, 24 Mar 2021 13:18:12 +0100
Subject: [PATCH] Remove name usage

---
 arkindex_worker/worker.py                   |  4 +---
 tests/test_cache.py                         |  2 +-
 tests/test_elements_worker/test_elements.py | 15 ++-------------
 3 files changed, 4 insertions(+), 17 deletions(-)

diff --git a/arkindex_worker/worker.py b/arkindex_worker/worker.py
index 1b412570..7d7d42fd 100644
--- a/arkindex_worker/worker.py
+++ b/arkindex_worker/worker.py
@@ -848,13 +848,11 @@ class ElementsWorker(BaseWorker):
         if self.cache:
             # Checking that we only received query_params handled by the cache
             assert set(query_params.keys()) <= {
-                "name",
                 "type",
                 "worker_version",
-            }, "When using the local cache, you can only filter by 'name', 'type' and/or 'worker_version'"
+            }, "When using the local cache, you can only filter by 'type' and/or 'worker_version'"
 
             conditions = [("parent_id", "=", convert_str_uuid_to_hex(element.id))]
-            conditions += [("name", "LIKE", f"%{name}%")] if name else []
             conditions += [("type", "=", type)] if type else []
             conditions += (
                 [("worker_version_id", "=", convert_str_uuid_to_hex(worker_version))]
diff --git a/tests/test_cache.py b/tests/test_cache.py
index 685cc1b3..526f1599 100644
--- a/tests/test_cache.py
+++ b/tests/test_cache.py
@@ -150,7 +150,7 @@ def test_fetch_with_where():
                 "=",
                 convert_str_uuid_to_hex("12341234-1234-1234-1234-123412341234"),
             ),
-            ("name", "LIKE", "%0%"),
+            ("id", "LIKE", "%1111%"),
         ],
     )
     assert [CachedElement(**dict(row)) for row in rows] == [ELEMENTS_TO_INSERT[0]]
diff --git a/tests/test_elements_worker/test_elements.py b/tests/test_elements_worker/test_elements.py
index 4b3f5d4e..03028cad 100644
--- a/tests/test_elements_worker/test_elements.py
+++ b/tests/test_elements_worker/test_elements.py
@@ -18,7 +18,6 @@ ELEMENTS_TO_INSERT = [
     CachedElement(
         id=convert_str_uuid_to_hex("11111111-1111-1111-1111-111111111111"),
         parent_id=convert_str_uuid_to_hex("12341234-1234-1234-1234-123412341234"),
-        name="0",
         type="something",
         polygon=json.dumps([[1, 1], [2, 2], [2, 1], [1, 2]]),
         worker_version_id=convert_str_uuid_to_hex(
@@ -28,7 +27,6 @@ ELEMENTS_TO_INSERT = [
     CachedElement(
         id=convert_str_uuid_to_hex("22222222-2222-2222-2222-222222222222"),
         parent_id=convert_str_uuid_to_hex("12341234-1234-1234-1234-123412341234"),
-        name="1",
         type="page",
         polygon=json.dumps([[1, 1], [2, 2], [2, 1], [1, 2]]),
         worker_version_id=convert_str_uuid_to_hex(
@@ -38,7 +36,6 @@ ELEMENTS_TO_INSERT = [
     CachedElement(
         id=convert_str_uuid_to_hex("33333333-3333-3333-3333-333333333333"),
         parent_id=convert_str_uuid_to_hex("12341234-1234-1234-1234-123412341234"),
-        name="10",
         type="something",
         polygon=json.dumps([[1, 1], [2, 2], [2, 1], [1, 2]]),
         worker_version_id=convert_str_uuid_to_hex(
@@ -950,7 +947,7 @@ def test_list_element_children_with_cache_unhandled_param(
         )
     assert (
         str(e.value)
-        == "When using the local cache, you can only filter by 'name', 'type' and/or 'worker_version'"
+        == "When using the local cache, you can only filter by 'type' and/or 'worker_version'"
     )
 
 
@@ -972,13 +969,6 @@ def test_list_element_children_with_cache(responses, mock_elements_worker_with_c
     ):
         assert child == expected_children[idx]
 
-    expected_children = ELEMENTS_TO_INSERT[1:]
-
-    for idx, child in enumerate(
-        mock_elements_worker_with_cache.list_element_children(element=elt, name="1")
-    ):
-        assert child == expected_children[idx]
-
     expected_children = [ELEMENTS_TO_INSERT[1]]
 
     for idx, child in enumerate(
@@ -995,12 +985,11 @@ def test_list_element_children_with_cache(responses, mock_elements_worker_with_c
     ):
         assert child == expected_children[idx]
 
-    expected_children = [ELEMENTS_TO_INSERT[1]]
+    expected_children = [ELEMENTS_TO_INSERT[0]]
 
     for idx, child in enumerate(
         mock_elements_worker_with_cache.list_element_children(
             element=elt,
-            name="O",
             type="something",
             worker_version="56785678-5678-5678-5678-567856785678",
         )
-- 
GitLab