From 891a5841da96fe528a974995d1766741d7cf92b4 Mon Sep 17 00:00:00 2001 From: kfilippopolitis Date: Thu, 11 Jan 2024 17:57:22 +0200 Subject: [PATCH] Update the monetdb image for the testing. --- mipdb/tables.py | 2 +- pyproject.toml | 2 +- tests/conftest.py | 4 ++-- tests/mocks.py | 12 ++++++------ tests/test_commands.py | 8 ++++---- tests/test_tables.py | 12 ++++++------ tests/test_usecases.py | 8 ++++---- 7 files changed, 24 insertions(+), 24 deletions(-) diff --git a/mipdb/tables.py b/mipdb/tables.py index ba09bb3..2bbc98e 100644 --- a/mipdb/tables.py +++ b/mipdb/tables.py @@ -331,7 +331,7 @@ def from_db(cls, schema, db): new_table = cls(schema) new_table.set_table( { - code: CommonDataElement.from_metadata(json.loads(metadata)[0]) + code: CommonDataElement.from_metadata(json.loads(metadata)) for code, metadata in res.items() } ) diff --git a/pyproject.toml b/pyproject.toml index ea16cdd..5680661 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "mipdb" -version = "2.4.6" +version = "2.4.7" description = "" authors = ["Your Name "] diff --git a/tests/conftest.py b/tests/conftest.py index 4b40bfc..af2c20b 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -22,7 +22,7 @@ IP = "127.0.0.1" PORT = 50123 USERNAME = "admin" -PASSWORD = "admin" +PASSWORD = "executor" DB_NAME = "db" DEFAULT_OPTIONS = [ @@ -65,7 +65,7 @@ def monetdb_container(): container = client.containers.get("mipdb-testing") except docker.errors.NotFound: container = client.containers.run( - "madgik/mipenginedb:dev", + "madgik/exareme2_db:latest", detach=True, ports={"50000/tcp": PORT}, name="mipdb-testing", diff --git a/tests/mocks.py b/tests/mocks.py index 92ed6f4..e0b9135 100644 --- a/tests/mocks.py +++ b/tests/mocks.py @@ -66,12 +66,12 @@ def get_dataset_status(self, dataset_id): def get_metadata(self, schema): return { - "var1": '[{"code": "var1", "sql_type": "text", "description": "", "label": "Variable 1", "methodology": "", "is_categorical": false, "type": "nominal"}]', - "subjectcode": '[{"label": "subjectcode", "code": "subjectcode", "sql_type": "text", "description": "", "methodology": "", "is_categorical": false, "type": "nominal"}]', - "var2": '[{"code": "var2", "sql_type": "text", "description": "", "enumerations": {"1": "Level1", "2.0": "Level2"}, "label": "Variable 2", "methodology": "", "is_categorical": true, "type": "nominal"}]', - "dataset": '[{"code": "dataset", "sql_type": "text", "description": "", "enumerations": {"dataset": "Dataset", "dataset1": "Dataset 1", "dataset2": "Dataset 2"}, "label": "Dataset", "methodology": "", "is_categorical": true, "type": "nominal"}]', - "var3": '[{"code": "var3", "sql_type": "real", "description": "", "label": "Variable 3", "methodology": "", "is_categorical": false, "min": 0, "max": 100, "type": "nominal"}]', - "var4": '[{"code": "var4", "sql_type": "int", "units": "years", "description": "", "label": "Variable 4", "methodology": "", "is_categorical": false, "type": "nominal"}]', + "var1": '{"code": "var1", "sql_type": "text", "description": "", "label": "Variable 1", "methodology": "", "is_categorical": false, "type": "nominal"}', + "subjectcode": '{"label": "subjectcode", "code": "subjectcode", "sql_type": "text", "description": "", "methodology": "", "is_categorical": false, "type": "nominal"}', + "var2": '{"code": "var2", "sql_type": "text", "description": "", "enumerations": {"1": "Level1", "2.0": "Level2"}, "label": "Variable 2", "methodology": "", "is_categorical": true, "type": "nominal"}', + "dataset": '{"code": "dataset", "sql_type": "text", "description": "", "enumerations": {"dataset": "Dataset", "dataset1": "Dataset 1", "dataset2": "Dataset 2"}, "label": "Dataset", "methodology": "", "is_categorical": true, "type": "nominal"}', + "var3": '{"code": "var3", "sql_type": "real", "description": "", "label": "Variable 3", "methodology": "", "is_categorical": false, "min": 0, "max": 100, "type": "nominal"}', + "var4": '{"code": "var4", "sql_type": "int", "units": "years", "description": "", "label": "Variable 4", "methodology": "", "is_categorical": false, "type": "nominal"}', } def get_data_model_status(self, data_model_id): diff --git a/tests/test_commands.py b/tests/test_commands.py index cdb2b3b..07dd135 100644 --- a/tests/test_commands.py +++ b/tests/test_commands.py @@ -685,7 +685,7 @@ def test_tag_dataset(db): (properties, *_), *_ = db.execute( f"select properties from mipdb_metadata.datasets" ).fetchall() - assert '{"tags": ["tag"], "properties": {}}' == properties + assert '{"tags":["tag"],"properties":{}}' == properties action_record = db.execute(f"select * from mipdb_metadata.actions").fetchall() action_id, action = action_record[3] assert action_id == 4 @@ -752,7 +752,7 @@ def test_untag_dataset(db): (properties, *_), *_ = db.execute( f"select properties from mipdb_metadata.datasets" ).fetchall() - assert '{"tags": [], "properties": {}}' == properties + assert '{"tags":[],"properties":{}}' == properties action_record = db.execute(f"select * from mipdb_metadata.actions").fetchall() action_id, action = action_record[3] assert action_id == 4 @@ -801,7 +801,7 @@ def test_property_dataset_addition(db): (properties, *_), *_ = db.execute( f"select properties from mipdb_metadata.datasets" ).fetchall() - assert '{"tags": [], "properties": {"key": "value"}}' == properties + assert '{"tags":[],"properties":{"key":"value"}}' == properties action_record = db.execute(f"select * from mipdb_metadata.actions").fetchall() action_id, action = action_record[3] assert action_id == 4 @@ -868,7 +868,7 @@ def test_property_dataset_deletion(db): (properties, *_), *_ = db.execute( f"select properties from mipdb_metadata.datasets" ).fetchall() - assert '{"tags": [], "properties": {}}' == properties + assert '{"tags":[],"properties":{}}' == properties action_record = db.execute(f"select * from mipdb_metadata.actions").fetchall() action_id, action = action_record[3] assert action_id == 4 diff --git a/tests/test_tables.py b/tests/test_tables.py index 3cb81be..c7d116c 100644 --- a/tests/test_tables.py +++ b/tests/test_tables.py @@ -155,12 +155,12 @@ def test_insert_values_with_db(self, db, data_model_metadata): ) result = [(name, json.loads(val)) for name, val in res.fetchall()] assert result == [ - ("var1", [False]), - ("subjectcode", [False]), - ("var2", [True]), - ("dataset", [True]), - ("var3", [False]), - ("var4", [False]), + ("var1", False), + ("subjectcode", False), + ("var2", True), + ("dataset", True), + ("var3", False), + ("var4", False), ] def test_get_values_from_cdes_full_schema_data(self, data_model_metadata): diff --git a/tests/test_usecases.py b/tests/test_usecases.py index ff2172c..387eaf3 100644 --- a/tests/test_usecases.py +++ b/tests/test_usecases.py @@ -955,7 +955,7 @@ def test_tag_dataset_with_db(db, data_model_metadata): ) properties = db.get_dataset_properties(1) - assert properties == '{"tags": ["tag"], "properties": {}}' + assert properties == '{"tags":["tag"],"properties":{}}' @pytest.mark.database @@ -993,7 +993,7 @@ def test_untag_dataset_with_db(db, data_model_metadata): ) properties = db.get_dataset_properties(1) - assert properties == '{"tags": ["tag2", "tag3"], "properties": {}}' + assert properties == '{"tags":["tag2","tag3"],"properties":{}}' @pytest.mark.database @@ -1015,7 +1015,7 @@ def test_add_property2dataset_with_db(db, data_model_metadata): ) properties = db.get_dataset_properties(1) - assert properties == '{"tags": [], "properties": {"key": "value"}}' + assert properties == '{"tags":[],"properties":{"key":"value"}}' @pytest.mark.database @@ -1060,7 +1060,7 @@ def test_remove_property_from_dataset_with_db(db, data_model_metadata): ) properties = db.get_dataset_properties(1) assert ( - properties == '{"tags": [], "properties": {"key": "value", "key1": "value1"}}' + properties == '{"tags":[],"properties":{"key":"value","key1":"value1"}}' )