Skip to content

Commit

Permalink
Removed unused engine from tests
Browse files Browse the repository at this point in the history
  • Loading branch information
josvandervelde committed Nov 21, 2023
1 parent 6b3e067 commit 47b254c
Show file tree
Hide file tree
Showing 14 changed files with 11 additions and 43 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import datetime

from sqlalchemy.engine import Engine

from converters.schema_converters import dataset_converter_dcatap_instance
from database.model.agent.person import Person
from database.model.ai_asset.license import License
Expand All @@ -13,7 +11,7 @@
from tests.testutils.paths import path_test_resources


def test_aiod_to_dcatap_happy_path(engine: Engine, dataset: Dataset):
def test_aiod_to_dcatap_happy_path(dataset: Dataset):
dataset.identifier = 1
dataset.license = License(name="a license")
dataset.alternate_name = [AlternateName(name="alias1"), AlternateName(name="alias2")]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import datetime

from sqlalchemy.engine import Engine

from converters.schema_converters import dataset_converter_schema_dot_org_instance
from database.model.agent.agent_table import AgentTable
from database.model.agent.contact import Contact
Expand All @@ -15,7 +13,7 @@
from tests.testutils.paths import path_test_resources


def test_aiod_to_schema_dot_org_happy_path(engine: Engine, dataset: Dataset):
def test_aiod_to_schema_dot_org_happy_path(dataset: Dataset):
dataset.identifier = 1
dataset.license = License(name="a license")
dataset.alternate_name = [AlternateName(name="alias1"), AlternateName(name="alias2")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import responses
from fastapi import status
from pytest import FixtureRequest
from sqlalchemy.engine import Engine
from starlette.testclient import TestClient

from authentication import keycloak_openid
Expand Down Expand Up @@ -51,7 +50,6 @@ def mock_response2(mocked_requests: responses.RequestsMock):

def set_up(
client: TestClient,
engine: Engine,
mocked_privileged_token: Mock,
body: dict,
person: Person,
Expand Down Expand Up @@ -79,9 +77,8 @@ def resource_name(request: FixtureRequest) -> str:
return request.param


def test_ai_asset_has_endopoints(
def test_ai_asset_has_endpoints(
client: TestClient,
engine: Engine,
mocked_privileged_token: Mock,
body_asset_with_single_distribution: dict,
person: Person,
Expand All @@ -96,7 +93,7 @@ def test_ai_asset_has_endopoints(
return a response with status code 200.
"""
body = copy.deepcopy(body_asset_with_single_distribution)
set_up(client, engine, mocked_privileged_token, body, person, resource_name)
set_up(client, mocked_privileged_token, body, person, resource_name)

default_endpoint = f"{resource_name}/v1/1/content"

Expand All @@ -111,7 +108,6 @@ def test_ai_asset_has_endopoints(

def test_endpoints_when_empty_distribution(
client: TestClient,
engine: Engine,
mocked_privileged_token: Mock,
body_asset: dict,
person: Person,
Expand All @@ -125,7 +121,7 @@ def test_endpoints_when_empty_distribution(
"""
body = copy.deepcopy(body_asset)
body["distribution"] = []
set_up(client, engine, mocked_privileged_token, body, person, SAMPLE_RESOURCE_NAME)
set_up(client, mocked_privileged_token, body, person, SAMPLE_RESOURCE_NAME)

response = client.get(SAMPLE_ENDPOINT)
assert response.status_code == status.HTTP_404_NOT_FOUND, response.json()
Expand All @@ -147,7 +143,6 @@ def body_asset_with_single_distribution(body_asset: dict) -> dict:

def test_endpoints_when_single_distribution(
client: TestClient,
engine: Engine,
mocked_privileged_token: Mock,
body_asset_with_single_distribution: dict,
person: Person,
Expand All @@ -160,7 +155,7 @@ def test_endpoints_when_single_distribution(
content, headers, and filename are returned.
"""
body = copy.deepcopy(body_asset_with_single_distribution)
set_up(client, engine, mocked_privileged_token, body, person, SAMPLE_RESOURCE_NAME)
set_up(client, mocked_privileged_token, body, person, SAMPLE_RESOURCE_NAME)

with responses.RequestsMock() as mocked_requests:
mock_response1(mocked_requests)
Expand Down Expand Up @@ -203,7 +198,6 @@ def body_asset_with_two_distributions(body_asset_with_single_distribution: dict)

def test_endpoints_when_two_distributions(
client: TestClient,
engine: Engine,
mocked_privileged_token: Mock,
body_asset_with_two_distributions: dict,
person: Person,
Expand All @@ -216,7 +210,7 @@ def test_endpoints_when_two_distributions(
content, headers, and filename are returned.
"""
body = copy.deepcopy(body_asset_with_two_distributions)
set_up(client, engine, mocked_privileged_token, body, person, SAMPLE_RESOURCE_NAME)
set_up(client, mocked_privileged_token, body, person, SAMPLE_RESOURCE_NAME)

with responses.RequestsMock() as mocked_requests:
mock_response1(mocked_requests)
Expand Down Expand Up @@ -259,7 +253,6 @@ def encoding_format(request: FixtureRequest) -> str:

def test_headers_when_distribution_has_missing_fields(
client: TestClient,
engine: Engine,
mocked_privileged_token: Mock,
body_asset_with_single_distribution: dict,
person: Person,
Expand All @@ -279,7 +272,7 @@ def test_headers_when_distribution_has_missing_fields(

alternate_filename = body["distribution"][0]["content_url"].split("/")[-1]

set_up(client, engine, mocked_privileged_token, body, person, SAMPLE_RESOURCE_NAME)
set_up(client, mocked_privileged_token, body, person, SAMPLE_RESOURCE_NAME)

with responses.RequestsMock() as mocked_requests:
mock_response1(mocked_requests)
Expand Down
3 changes: 1 addition & 2 deletions src/tests/routers/enum_routers/test_license_router.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from sqlalchemy.engine import Engine
from starlette.testclient import TestClient

from database.model.ai_asset.license import License
Expand All @@ -7,7 +6,7 @@
from database.session import DbSession


def test_happy_path(client: TestClient, engine: Engine, dataset: Dataset, publication: Publication):
def test_happy_path(client: TestClient, dataset: Dataset, publication: Publication):

dataset.license = License(name="license 1")
publication.license = License(name="license 2")
Expand Down
3 changes: 0 additions & 3 deletions src/tests/routers/parent_routers/test_agent_router.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import datetime

from sqlalchemy.engine import Engine
from starlette.testclient import TestClient

from database.model.agent.organisation import Organisation
Expand All @@ -10,7 +9,6 @@

def test_happy_path(
client: TestClient,
engine: Engine,
organisation: Organisation,
person: Person,
):
Expand Down Expand Up @@ -39,7 +37,6 @@ def test_happy_path(

def test_ignore_deleted(
client: TestClient,
engine: Engine,
organisation: Organisation,
person: Person,
):
Expand Down
2 changes: 0 additions & 2 deletions src/tests/routers/parent_routers/test_ai_asset_router.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from sqlalchemy.engine import Engine
from starlette.testclient import TestClient

from database.model.dataset.dataset import Dataset
Expand All @@ -8,7 +7,6 @@

def test_happy_path(
client: TestClient,
engine: Engine,
dataset: Dataset,
publication: Publication,
):
Expand Down
2 changes: 0 additions & 2 deletions src/tests/routers/parent_routers/test_ai_resource_router.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from sqlalchemy.engine import Engine
from starlette.testclient import TestClient

from database.model.agent.organisation import Organisation
Expand All @@ -8,7 +7,6 @@

def test_happy_path(
client: TestClient,
engine: Engine,
organisation: Organisation,
person: Person,
):
Expand Down
2 changes: 0 additions & 2 deletions src/tests/routers/resource_routers/test_router_case_study.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
import copy
from unittest.mock import Mock

from sqlalchemy.engine import Engine
from starlette.testclient import TestClient

from authentication import keycloak_openid


def test_happy_path(
client: TestClient,
engine: Engine,
mocked_privileged_token: Mock,
body_asset: dict,
):
Expand Down
2 changes: 0 additions & 2 deletions src/tests/routers/resource_routers/test_router_dataset.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import copy
from unittest.mock import Mock

from sqlalchemy.engine import Engine
from starlette.testclient import TestClient

from authentication import keycloak_openid
Expand All @@ -11,7 +10,6 @@

def test_happy_path(
client: TestClient,
engine: Engine,
mocked_privileged_token: Mock,
body_asset: dict,
person: Person,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
import copy
from unittest.mock import Mock

from sqlalchemy.engine import Engine
from starlette.testclient import TestClient

from authentication import keycloak_openid


def test_happy_path(
client: TestClient,
engine: Engine,
mocked_privileged_token: Mock,
body_asset: dict,
):
Expand Down
2 changes: 0 additions & 2 deletions src/tests/routers/resource_routers/test_router_experiment.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
import copy
from unittest.mock import Mock

from sqlalchemy.engine import Engine
from starlette.testclient import TestClient

from authentication import keycloak_openid


def test_happy_path(
client: TestClient,
engine: Engine,
mocked_privileged_token: Mock,
body_asset: dict,
):
Expand Down
2 changes: 0 additions & 2 deletions src/tests/routers/resource_routers/test_router_publication.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import copy
from unittest.mock import Mock

from sqlalchemy.engine import Engine
from starlette.testclient import TestClient

from authentication import keycloak_openid
Expand All @@ -10,7 +9,6 @@

def test_happy_path(
client: TestClient,
engine: Engine,
mocked_privileged_token: Mock,
body_asset: dict,
dataset: Dataset,
Expand Down
2 changes: 0 additions & 2 deletions src/tests/routers/resource_routers/test_router_service.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
import copy
from unittest.mock import Mock

from sqlalchemy.engine import Engine
from starlette.testclient import TestClient

from authentication import keycloak_openid


def test_happy_path(
client: TestClient,
engine: Engine,
mocked_privileged_token: Mock,
body_resource: dict,
):
Expand Down
5 changes: 2 additions & 3 deletions src/tests/uploader/huggingface/test_dataset_uploader.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import huggingface_hub
import responses
from sqlalchemy.engine import Engine
from starlette.testclient import TestClient

from authentication import keycloak_openid
Expand All @@ -13,7 +12,7 @@


def test_happy_path_new_repository(
client: TestClient, engine: Engine, mocked_privileged_token: Mock, dataset: Dataset
client: TestClient, mocked_privileged_token: Mock, dataset: Dataset
):
keycloak_openid.userinfo = mocked_privileged_token
with DbSession() as session:
Expand Down Expand Up @@ -48,7 +47,7 @@ def test_happy_path_new_repository(
assert id_response == 1


def test_repo_already_exists(client: TestClient, engine: Engine, mocked_privileged_token: Mock):
def test_repo_already_exists(client: TestClient, mocked_privileged_token: Mock):
keycloak_openid.userinfo = mocked_privileged_token
dataset_id = 1
with DbSession() as session:
Expand Down

0 comments on commit 47b254c

Please sign in to comment.