Skip to content

Commit

Permalink
fix more issues
Browse files Browse the repository at this point in the history
  • Loading branch information
seebi committed Sep 13, 2024
1 parent b15b28f commit ee83f2a
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 12 deletions.
8 changes: 5 additions & 3 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""pytest conftest module"""

import io
from collections.abc import Generator
from dataclasses import dataclass

import pytest
Expand All @@ -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,
Expand All @@ -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)


Expand Down
1 change: 1 addition & 0 deletions tests/parameter_types/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""tests"""
2 changes: 1 addition & 1 deletion tests/parameter_types/test_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
2 changes: 1 addition & 1 deletion tests/parameter_types/test_password.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 []

Expand Down
15 changes: 9 additions & 6 deletions tests/test_icon.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down

0 comments on commit ee83f2a

Please sign in to comment.