From e2c63f348f47194f006874b2fea7aa266161ceb8 Mon Sep 17 00:00:00 2001 From: Erwan Rouchet <rouchet@teklia.com> Date: Wed, 24 Mar 2021 11:12:15 +0000 Subject: [PATCH] Remove name support in the cache --- arkindex_worker/cache.py | 3 +-- arkindex_worker/worker.py | 1 - tests/data/cache/lines.sqlite | Bin 12288 -> 12288 bytes tests/data/cache/tables.sqlite | Bin 12288 -> 12288 bytes tests/test_cache.py | 6 ++---- tests/test_elements_worker/test_elements.py | 1 - 6 files changed, 3 insertions(+), 8 deletions(-) diff --git a/arkindex_worker/cache.py b/arkindex_worker/cache.py index 2a36c219..9bb6c0fa 100644 --- a/arkindex_worker/cache.py +++ b/arkindex_worker/cache.py @@ -7,7 +7,6 @@ from arkindex_worker import logger SQL_ELEMENTS_TABLE_CREATION = """CREATE TABLE IF NOT EXISTS elements ( id VARCHAR(32) PRIMARY KEY, parent_id VARCHAR(32), - name TEXT NOT NULL, type TEXT NOT NULL, polygon TEXT, initial BOOLEAN DEFAULT 0 NOT NULL, @@ -17,7 +16,7 @@ SQL_ELEMENTS_TABLE_CREATION = """CREATE TABLE IF NOT EXISTS elements ( CachedElement = namedtuple( "CachedElement", - ["id", "name", "type", "polygon", "worker_version_id", "parent_id", "initial"], + ["id", "type", "polygon", "worker_version_id", "parent_id", "initial"], defaults=[None, 0], ) diff --git a/arkindex_worker/worker.py b/arkindex_worker/worker.py index ec61b14b..541cc286 100644 --- a/arkindex_worker/worker.py +++ b/arkindex_worker/worker.py @@ -476,7 +476,6 @@ class ElementsWorker(BaseWorker): CachedElement( id=convert_str_uuid_to_hex(created_ids[idx]["id"]), parent_id=parent_id_hex, - name=element["name"], type=element["type"], polygon=json.dumps(element["polygon"]), worker_version_id=worker_version_id_hex, diff --git a/tests/data/cache/lines.sqlite b/tests/data/cache/lines.sqlite index 4294b9b0f3789629fb466debb0d8931f589f9c59..ea881e4f1bb2143f560ca81ac6435842494c95f5 100644 GIT binary patch delta 88 zcmZojXh@il#de>8?>_(W&4L2?d|ZvGjO^mFvW(5LlTYxaPY&SU#&(N=KbP;;W<iB> rd~A&ZOzghClkdv8Ox`Z<$<-*p2;|E9a`;Yus4qWxs=VT6ps)Y{?a&+I delta 127 zcmZojXh@il#kP-uZy*2hjfH-ETup3@?BcSrjLq?rU-G3ZD){+_DENi?_~>vc06|`2 zZmL3vYXndXDn2=Ye;eC12L5cmYnufXPVuof3Ndl``tnbHAm_qpIC;CgCwHR|BS=Kv Vm&14RLw)(l)8rKy4K@R11OROEB?bTh diff --git a/tests/data/cache/tables.sqlite b/tests/data/cache/tables.sqlite index be29e25631f18d386ad8c644ead09e91792a3d43..efc107cd7506757f92df1ee011b670738228b8b2 100644 GIT binary patch delta 38 ucmZojXh@il#de>8?>_(W&4L2?d|ZvGjO^mFvW(5LlP~h+ZVuyLr2qi^@eE%8 delta 56 zcmZojXh@il#de&5?>PVQjfLTST#dDi?BcSrjLp82U-IP&<t65(DulR3geds=197O2 K&*lLB4GI7rD-uZn diff --git a/tests/test_cache.py b/tests/test_cache.py index fde2c681..fb3c28a1 100644 --- a/tests/test_cache.py +++ b/tests/test_cache.py @@ -14,7 +14,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( @@ -24,7 +23,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="something", polygon=json.dumps([[1, 1], [2, 2], [2, 1], [1, 2]]), worker_version_id=convert_str_uuid_to_hex( @@ -78,10 +76,10 @@ def test_create_tables(): name = table["name"] expected_table = expected_cache.cursor.execute( f"SELECT sql FROM sqlite_master WHERE name = '{name}'" - ).fetchone() + ).fetchone()["sql"] generated_table = cache.cursor.execute( f"SELECT sql FROM sqlite_master WHERE name = '{name}'" - ).fetchone() + ).fetchone()["sql"] assert expected_table == generated_table diff --git a/tests/test_elements_worker/test_elements.py b/tests/test_elements_worker/test_elements.py index 776885fa..b0ad3486 100644 --- a/tests/test_elements_worker/test_elements.py +++ b/tests/test_elements_worker/test_elements.py @@ -691,7 +691,6 @@ def test_create_elements(responses, mock_elements_worker_with_cache): CachedElement( id=convert_str_uuid_to_hex("497f6eca-6276-4993-bfeb-53cbbbba6f08"), 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( -- GitLab