From 33302eac299c716bfc53aee9cfeff223edd82c68 Mon Sep 17 00:00:00 2001 From: charan Date: Mon, 30 Nov 2026 19:06:00 +0530 Subject: [PATCH 1/2] test: re-enable and fix skipped deployment tests --- tests/test_deploy.py | 70 ++++++++++++++++++++++++++------------------ 1 file changed, 41 insertions(+), 29 deletions(-) diff --git a/tests/test_deploy.py b/tests/test_deploy.py index 679f11fe..7ab64004 100644 --- a/tests/test_deploy.py +++ b/tests/test_deploy.py @@ -39,56 +39,63 @@ def test_get_content_variants(): _ = _get_content_variants("https://example.com/file.ttl|invalidformat") -@pytest.mark.skip(reason="temporarily disabled since code needs fixing") -def test_distribution_cases(): - metadata_args_with_filler = OrderedDict() +EXAMPLE_SHA256 = "088e6161bf8b4861bdd4e9f517be4441b35a15346cb9d2d3c6d2e3d6cd412030" +EXAMPLE_SIZE = 59986 + + +def test_distribution_cases(monkeypatch): + monkeypatch.setattr( + "databusclient.api.deploy._load_file_stats", + lambda _url: (EXAMPLE_SHA256, EXAMPLE_SIZE), + ) + metadata_args_with_filler = OrderedDict() metadata_args_with_filler["type=config_source=databus"] = "" metadata_args_with_filler["yml"] = None metadata_args_with_filler["none"] = None - metadata_args_with_filler[ - "79582a2a7712c0ce78a74bb55b253dc2064931364cf9c17c827370edf9b7e4f1:56737" - ] = None + metadata_args_with_filler[f"{EXAMPLE_SHA256}:{EXAMPLE_SIZE}"] = None # test by leaving out an argument each - artifact_name = "databusclient-pytest" - uri = "https://raw.githubusercontent.com/dbpedia/databus/master/server/app/api/swagger.yml" + uri = EXAMPLE_URL parameters = list(metadata_args_with_filler.keys()) + full_dst_string = f"{uri}|{'|'.join(parameters)}" - for i in range(0, len(metadata_args_with_filler.keys())): + for i in range(len(parameters)): if i == 1: continue dst_string = f"{uri}" - for j in range(0, len(metadata_args_with_filler.keys())): + for j in range(len(parameters)): if j == i: replacement = metadata_args_with_filler[parameters[j]] - if replacement is None: - pass - else: + if replacement is not None: dst_string += f"|{replacement}" else: dst_string += f"|{parameters[j]}" - print(f"{dst_string=}") ( - name, cvs, - formatExtension, + format_extension, compression, sha256sum, content_length, - ) = get_file_info(artifact_name, dst_string) + ) = get_file_info(dst_string) created_dst_str = create_distribution( - uri, cvs, formatExtension, compression, (sha256sum, content_length) + uri, cvs, format_extension, compression, (sha256sum, content_length) ) - assert dst_string == created_dst_str + # Omitting compression (i == 2) or stats (i == 3) resolves to defaults + expected_dst_str = dst_string if i == 0 else full_dst_string + assert created_dst_str == expected_dst_str -@pytest.mark.skip(reason="temporarily disabled since code needs fixing") -def test_empty_cvs(): +def test_empty_cvs(monkeypatch): + monkeypatch.setattr( + "databusclient.api.deploy._load_file_stats", + lambda _url: (EXAMPLE_SHA256, EXAMPLE_SIZE), + ) + dst = [create_distribution(url=EXAMPLE_URL, cvs={})] dataset = create_dataset( @@ -104,8 +111,15 @@ def test_empty_cvs(): "@context": "https://downloads.dbpedia.org/databus/context.jsonld", "@graph": [ { - "@type": "Dataset", - "@id": "https://dev.databus.dbpedia.org/user/group/artifact/1970.01.01#Dataset", + "@id": "https://dev.databus.dbpedia.org/user/group/artifact", + "@type": "Artifact", + "title": "Test Title", + "abstract": "Test abstract blabla", + "description": "Test description blabla", + }, + { + "@type": ["Version", "Dataset"], + "@id": "https://dev.databus.dbpedia.org/user/group/artifact/1970.01.01", "hasVersion": "1970.01.01", "title": "Test Title", "abstract": "Test abstract blabla", @@ -113,18 +127,16 @@ def test_empty_cvs(): "license": "https://license.url/test/", "distribution": [ { - "@id": "https://dev.databus.dbpedia.org/user/group/artifact/1970.01.01#artifact.yml", "@type": "Part", - "file": "https://dev.databus.dbpedia.org/user/group/artifact/1970.01.01/artifact.yml", "formatExtension": "yml", "compression": "none", "downloadURL": EXAMPLE_URL, - "byteSize": 59986, - "sha256sum": "088e6161bf8b4861bdd4e9f517be4441b35a15346cb9d2d3c6d2e3d6cd412030", + "byteSize": EXAMPLE_SIZE, + "sha256sum": EXAMPLE_SHA256, } ], - } + }, ], } - assert dataset == correct_dataset + assert dataset == correct_dataset \ No newline at end of file From b0f145bb1be0dc6325775581d6a3b6b229d7aee9 Mon Sep 17 00:00:00 2001 From: charan Date: Mon, 30 Nov 2026 19:08:17 +0530 Subject: [PATCH 2/2] style: format test_deploy.py with ruff --- tests/test_deploy.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_deploy.py b/tests/test_deploy.py index 7ab64004..29b038aa 100644 --- a/tests/test_deploy.py +++ b/tests/test_deploy.py @@ -139,4 +139,4 @@ def test_empty_cvs(monkeypatch): ], } - assert dataset == correct_dataset \ No newline at end of file + assert dataset == correct_dataset