From ee83f2a50937d70a052b378eae54ef9fe53cd12c Mon Sep 17 00:00:00 2001 From: Sebastian Tramp Date: Fri, 13 Sep 2024 14:19:01 +0200 Subject: [PATCH] fix more issues --- tests/conftest.py | 8 +++++--- tests/parameter_types/__init__.py | 1 + tests/parameter_types/test_dataset.py | 2 +- tests/parameter_types/test_password.py | 2 +- tests/test_icon.py | 15 +++++++++------ tests/utils.py | 2 +- 6 files changed, 18 insertions(+), 12 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index a905f53..c2040de 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,6 +1,7 @@ """pytest conftest module""" import io +from collections.abc import Generator from dataclasses import dataclass import pytest @@ -17,8 +18,8 @@ @pytest.fixture(name="json_dataset", scope="module") -def _json_dataset(): - """Setup""" +def _json_dataset() -> Generator[dict, None, None]: + """Provide a dataset""" make_new_project(PROJECT_NAME) make_new_dataset( project_name=PROJECT_NAME, @@ -27,7 +28,8 @@ def _json_dataset(): parameters={"file": RESOURCE_NAME}, autoconfigure=False, ) - yield get_dataset(PROJECT_NAME, DATASET_NAME) + dataset = get_dataset(PROJECT_NAME, DATASET_NAME) + yield dataset delete_project(PROJECT_NAME) diff --git a/tests/parameter_types/__init__.py b/tests/parameter_types/__init__.py index e69de29..0e9f173 100644 --- a/tests/parameter_types/__init__.py +++ b/tests/parameter_types/__init__.py @@ -0,0 +1 @@ +"""tests""" \ No newline at end of file diff --git a/tests/parameter_types/test_dataset.py b/tests/parameter_types/test_dataset.py index fae1852..b77e394 100644 --- a/tests/parameter_types/test_dataset.py +++ b/tests/parameter_types/test_dataset.py @@ -5,7 +5,7 @@ @needs_cmem -def test_dataset_parameter_type_completion(json_dataset) -> None: +def test_dataset_parameter_type_completion(json_dataset: dict) -> None: """Test dataset parameter type completion""" project_name = json_dataset["project"] dataset_name = json_dataset["id"] diff --git a/tests/parameter_types/test_password.py b/tests/parameter_types/test_password.py index b443765..b2a63ad 100644 --- a/tests/parameter_types/test_password.py +++ b/tests/parameter_types/test_password.py @@ -25,7 +25,7 @@ class MyTransformPlugin(TransformPlugin): def __init__(self, password: Password) -> None: self.password = password - def transform(self, inputs: Sequence[Sequence[str]]) -> Sequence[str]: + def transform(self, inputs: Sequence[Sequence[str]]) -> Sequence[str]: # noqa: ARG002 """Test transform""" return [] diff --git a/tests/test_icon.py b/tests/test_icon.py index 0b67a8c..b305f74 100644 --- a/tests/test_icon.py +++ b/tests/test_icon.py @@ -17,32 +17,35 @@ class MyWorkflowPlugin(WorkflowPlugin): """My Workflow Plugin Class""" - def execute(self, inputs: Sequence[Entities], context: ExecutionContext) -> None: - return None + def execute(self, inputs: Sequence[Entities], context: ExecutionContext) -> None: # noqa: ARG002 + """Execute the workflow plugin on a given collection of entities.""" + return def test_for_errors() -> None: """Test Icon inits with errors.""" with pytest.raises(FileNotFoundError): Icon(file_name="no.file", package=__package__) - with pytest.raises(ValueError): + with pytest.raises(ValueError, match="^Guessed mime type.*does not start with.*image.*"): Icon(file_name="icons/test.txt", package=__package__) - with pytest.raises(ValueError): + with pytest.raises(ValueError, match="^Could not guess the mime type of the file"): Icon(file_name="icons/test.nomime", package=__package__) def test_svg() -> None: """Test SVG icon""" icon = Icon(file_name="icons/test.svg", package=__package__) + data_iri_length = 906 assert icon.mime_type == "image/svg+xml" - assert len(str(icon)) == 906 + assert len(str(icon)) == data_iri_length def test_png() -> None: """Test PNG icon""" icon = Icon(file_name="icons/test.png", package=__package__) + data_iri_length = 63818 assert icon.mime_type == "image/png" - assert len(str(icon)) == 63818 + assert len(str(icon)) == data_iri_length def test_plugin_init() -> None: diff --git a/tests/utils.py b/tests/utils.py index 7f5cda7..8d88234 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -21,7 +21,7 @@ class TestUserContext(UserContext): def __init__(self): # get access token from default service account - access_token: str = get_token()["access_token"] # type: ignore + access_token: str = get_token()["access_token"] self.token = lambda: access_token