Skip to content

Commit

Permalink
refac:
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonas1312 committed Oct 5, 2023
1 parent 4c4712f commit d9d7f4f
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 13 deletions.
9 changes: 4 additions & 5 deletions tests/unit/services/export/test_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -795,6 +795,7 @@ def test_export_with_asset_filter_kwargs(mocker):
"kili.services.export.format.base.get_project", return_value=get_project_return_val
)
mocker.patch.object(KiliExporter, "process_and_save", return_value=None)
mocker.patch.object(KiliExporter, "_check_and_ensure_asset_access", return_value=None)
kili = QueriesLabel()
kili.api_endpoint = "https://" # type: ignore
kili.api_key = "" # type: ignore
Expand Down Expand Up @@ -876,6 +877,7 @@ def test_export_with_asset_filter_kwargs_unknown_arg(mocker):
)
mocker.patch.object(KiliExporter, "_check_arguments_compatibility", return_value=None)
mocker.patch.object(KiliExporter, "_check_project_compatibility", return_value=None)
mocker.patch.object(KiliExporter, "_check_and_ensure_asset_access", return_value=None)
kili = QueriesLabel()
kili.api_endpoint = "https://" # type: ignore
kili.api_key = "" # type: ignore
Expand Down Expand Up @@ -918,11 +920,7 @@ def mock_kili(mocker, with_data_connection):
mocker.patch(
"kili.services.export.format.base.get_project", return_value=get_project_return_val
)
if with_data_connection:
mocker.patch(
"kili.services.export.format.base.DataConnectionsQuery.__call__",
return_value=(i for i in [{"id": "fake_data_connection_id"}]),
)
mocker.patch.object(AbstractExporter, "_has_data_connection", return_value=with_data_connection)

kili = QueriesLabel()
kili.kili_api_gateway = mocker.MagicMock()
Expand All @@ -938,6 +936,7 @@ def test_when_exporting_with_assets_given_a_project_with_data_connection_then_it
kili.api_key = "" # type: ignore
kili.graphql_client = mocker.MagicMock()
kili.http_client = mocker.MagicMock()
mocker.patch.object(AbstractExporter, "_has_data_connection", return_value=True)

with pytest.raises(
NotCompatibleOptions,
Expand Down
6 changes: 2 additions & 4 deletions tests/unit/services/export/test_geojson.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

from kili.entrypoints.queries.label import QueriesLabel
from kili.orm import Asset
from kili.services.export import AbstractExporter


def test_kili_export_labels_geojson(mocker: pytest_mock.MockerFixture):
Expand All @@ -22,10 +23,7 @@ def test_kili_export_labels_geojson(mocker: pytest_mock.MockerFixture):
mocker.patch(
"kili.services.export.format.base.get_project", return_value=get_project_return_val
)
mocker.patch(
"kili.services.export.format.base.DataConnectionsQuery.__call__",
return_value=(i for i in [{"id": "fake_data_connection_id"}]),
)
mocker.patch.object(AbstractExporter, "_check_and_ensure_asset_access", return_value=None)
mocker.patch(
"kili.services.export.format.base.fetch_assets",
return_value=[
Expand Down
3 changes: 3 additions & 0 deletions tests/unit/services/export/test_kili.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ def test_kili_export_labels_non_normalized_pdf(mocker: pytest_mock.MockerFixture
)
],
)
mocker.patch.object(AbstractExporter, "_check_and_ensure_asset_access", return_value=None)

kili = QueriesLabel()
kili.api_endpoint = "https://" # type: ignore
Expand Down Expand Up @@ -385,6 +386,7 @@ def test_kili_export_labels_non_normalized_image(mocker: pytest_mock.MockerFixtu
)
],
)
mocker.patch.object(AbstractExporter, "_check_and_ensure_asset_access", return_value=None)

kili = QueriesLabel()
kili.api_endpoint = "https://" # type: ignore
Expand Down Expand Up @@ -460,6 +462,7 @@ def test_kili_export_labels_non_normalized_video(mocker: pytest_mock.MockerFixtu
)
],
)
mocker.patch.object(AbstractExporter, "_check_and_ensure_asset_access", return_value=None)

kili = QueriesLabel()
kili.api_endpoint = "https://" # type: ignore
Expand Down
6 changes: 2 additions & 4 deletions tests/unit/services/export/test_voc.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import pytest

from kili.entrypoints.queries.label import QueriesLabel
from kili.services.export import VocExporter
from kili.services.export.exceptions import NotCompatibleOptions
from kili.services.export.format.voc import _convert_from_kili_to_voc_format
from tests.fakes.fake_data import asset_image_1, asset_image_1_without_annotation
Expand Down Expand Up @@ -49,10 +50,7 @@ def test_when_exporting_to_voc_given_a_project_with_data_connection_then_it_shou
mocker.patch(
"kili.services.export.format.base.get_project", return_value=get_project_return_val
)
mocker.patch(
"kili.services.export.format.base.DataConnectionsQuery.__call__",
return_value=(i for i in [{"id": "fake_data_connection_id"}]),
)
mocker.patch.object(VocExporter, "_has_data_connection", return_value=True)

kili = QueriesLabel()
kili.api_endpoint = "https://" # type: ignore
Expand Down
3 changes: 3 additions & 0 deletions tests/unit/services/export/test_yolo.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from kili.adapters.http_client import HttpClient
from kili.entrypoints.queries.label import QueriesLabel
from kili.orm import Asset
from kili.services.export import YoloExporter
from kili.services.export.format.yolo import (
_convert_from_kili_to_yolo_format,
_process_asset,
Expand Down Expand Up @@ -283,6 +284,7 @@ def test_yolo_v8_merged(mocker: pytest_mock.MockerFixture):
"kili.services.export.format.base.fetch_assets",
return_value=[Asset(asset) for asset in assets],
)
mocker.patch.object(YoloExporter, "_check_and_ensure_asset_access", return_value=None)

kili = QueriesLabel()
kili.api_endpoint = "https://" # type: ignore
Expand Down Expand Up @@ -334,6 +336,7 @@ def test_yolo_v8_split_jobs(mocker: pytest_mock.MockerFixture):
"kili.services.export.format.base.fetch_assets",
return_value=[Asset(asset) for asset in assets],
)
mocker.patch.object(YoloExporter, "_check_and_ensure_asset_access", return_value=None)

kili = QueriesLabel()
kili.api_endpoint = "https://" # type: ignore
Expand Down

0 comments on commit d9d7f4f

Please sign in to comment.