From 7450d6bfdcbf67e308aef5738e8546e8faf0ce38 Mon Sep 17 00:00:00 2001 From: kena vyas Date: Thu, 23 Jan 2025 15:42:07 +0000 Subject: [PATCH] black check --- digital_land/expectations/operation.py | 4 ++-- tests/integration/expectations/test_operation.py | 13 +++++++------ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/digital_land/expectations/operation.py b/digital_land/expectations/operation.py index b8905756..0ed3f265 100644 --- a/digital_land/expectations/operation.py +++ b/digital_land/expectations/operation.py @@ -146,7 +146,7 @@ def count_deleted_entities( resource_list = get_resource["resource"].to_list() # use resource list to get current entities - query = f"""select e.reference,fe.entry_number,f.entity,e.name,e.organisation_entity + query = f"""select f.entity from fact_resource fe join fact f on fe.fact=f.fact join entity e on f.entity=e.entity where resource in ({','.join(f"'{x}'" for x in resource_list)}) group by reference @@ -156,7 +156,7 @@ def count_deleted_entities( # get entities from entity table to compare against resource entities query = f""" - select reference from entity where organisation_entity = '{organisation_entity}'; + select entity from entity where organisation_entity = '{organisation_entity}'; """ rows = conn.execute(query).fetchall() get_entities = [row[0] for row in rows] diff --git a/tests/integration/expectations/test_operation.py b/tests/integration/expectations/test_operation.py index aabb020d..1efe87d9 100644 --- a/tests/integration/expectations/test_operation.py +++ b/tests/integration/expectations/test_operation.py @@ -122,10 +122,10 @@ def test_count_deleted_entities(dataset_path, mocker): # load data into sqlite for entity, fact_resource and fact table test_entity_data = pd.DataFrame.from_dict( { - "entity": ["1001"], - "name": ["test1"], - "organisation_entity": [109], - "reference": ["ref1"], + "entity": ["1001", "1002"], + "name": ["test1", "test2"], + "organisation_entity": [109, 109], + "reference": ["ref1", "ref2"], } ) @@ -166,10 +166,11 @@ def test_count_deleted_entities(dataset_path, mocker): ) assert ( - passed + not passed ), f"test failed : expected {details['expected']} but got {details['actual']} entities" assert message, "test requires a message" - detail_keys = ["actual", "expected"] + detail_keys = ["actual", "expected", "entities"] for key in detail_keys: assert key in details, f"{key} missing from details" + assert "1002" in details["entities"]