Skip to content
Snippets Groups Projects
Commit 6da4df02 authored by Eva Bardou's avatar Eva Bardou
Browse files

Remove name usage

parent 5aeccbe1
No related branches found
No related tags found
1 merge request!68Retrieve children elements from SQLite cache in list_element_children
This commit is part of merge request !68. Comments created here will be created in the context of that merge request.
......@@ -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))]
......
......@@ -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]]
......@@ -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",
)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment