diff --git a/tests/integration/use_cases/test_asset.py b/tests/integration/use_cases/test_asset.py index 0007fc80c..73eb413f0 100644 --- a/tests/integration/use_cases/test_asset.py +++ b/tests/integration/use_cases/test_asset.py @@ -110,7 +110,7 @@ def test_given_query_parameters_I_can_query_assets_and_download_their_media( kili_api_gateway: KiliAPIGateway, mocker ): # mocking - kili_api_gateway.get_project.return_value = {"inputType": "IMAGE"} + kili_api_gateway.get_project.return_value = {"inputType": "IMAGE", "dataConnections": None} media_downlaoder_mock = mocker.patch.object(MediaDownloader, "__init__", return_value=None) # given parameters to query assets diff --git a/tests/unit/services/export/test_coco.py b/tests/unit/services/export/test_coco.py index d9d44a25f..b173fec9f 100644 --- a/tests/unit/services/export/test_coco.py +++ b/tests/unit/services/export/test_coco.py @@ -16,7 +16,6 @@ _get_coco_categories_with_mapping, _get_coco_geometry_from_kili_bpoly, ) -from kili.services.export.format.kili import KiliExporter from kili.services.types import Job, JobName from kili.utils.tempfile import TemporaryDirectory @@ -579,12 +578,9 @@ def test_when_exporting_to_coco_given_a_project_with_data_connection_then_it_sho mocker.patch( "kili.services.export.format.base.get_project", return_value=get_project_return_val ) - mocker.patch.object(KiliExporter, "_check_arguments_compatibility", return_value=None) - mocker.patch.object(KiliExporter, "_check_project_compatibility", return_value=None) - mocker.patch( - "kili.services.export.format.base.DataConnectionsQuery.__call__", - return_value=(i for i in [{"id": "fake_data_connection_id"}]), - ) + mocker.patch.object(CocoExporter, "_check_arguments_compatibility", return_value=None) + mocker.patch.object(CocoExporter, "_check_project_compatibility", return_value=None) + mocker.patch.object(CocoExporter, "_has_data_connection", return_value=True) kili = QueriesLabel() kili.api_key = "" # type: ignore diff --git a/tests/unit/services/export/test_export.py b/tests/unit/services/export/test_export.py index f743a8b68..500c25c8b 100644 --- a/tests/unit/services/export/test_export.py +++ b/tests/unit/services/export/test_export.py @@ -14,7 +14,7 @@ from kili.domain.asset import AssetFilters from kili.entrypoints.queries.label import QueriesLabel from kili.orm import Asset -from kili.services.export import export_labels +from kili.services.export import AbstractExporter, export_labels from kili.services.export.exceptions import ( NoCompatibleJobError, NotCompatibleInputType, @@ -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, "_has_data_connection", return_value=False) kili = QueriesLabel() kili.api_endpoint = "https://" # type: ignore kili.api_key = "" # type: ignore @@ -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, "_has_data_connection", return_value=False) kili = QueriesLabel() kili.api_endpoint = "https://" # type: ignore kili.api_key = "" # type: ignore @@ -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() diff --git a/tests/unit/services/export/test_geojson.py b/tests/unit/services/export/test_geojson.py index 51ab7036b..5c13da0f3 100644 --- a/tests/unit/services/export/test_geojson.py +++ b/tests/unit/services/export/test_geojson.py @@ -7,6 +7,7 @@ from kili.entrypoints.queries.label import QueriesLabel from kili.orm import Asset +from kili.services.export.format.geojson import GeoJsonExporter def test_kili_export_labels_geojson(mocker: pytest_mock.MockerFixture): @@ -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(GeoJsonExporter, "_has_data_connection", return_value=False) mocker.patch( "kili.services.export.format.base.fetch_assets", return_value=[ diff --git a/tests/unit/services/export/test_kili.py b/tests/unit/services/export/test_kili.py index c3c7f0f76..668262383 100644 --- a/tests/unit/services/export/test_kili.py +++ b/tests/unit/services/export/test_kili.py @@ -189,6 +189,7 @@ def test_kili_exporter_convert_to_pixel_coords_pdf(mocker: pytest_mock.MockerFix def test_kili_export_labels_non_normalized_pdf(mocker: pytest_mock.MockerFixture): get_project_return_val = { "inputType": "PDF", + "dataConnections": None, "id": "fake_proj_id", "title": "fake_proj_title", "description": "fake_proj_description", @@ -273,6 +274,7 @@ def test_kili_export_labels_non_normalized_image(mocker: pytest_mock.MockerFixtu get_project_return_val = { "id": "fake_proj_id", "title": "hgfhfg", + "dataConnections": None, "inputType": "IMAGE", "jsonInterface": { "jobs": { @@ -444,6 +446,7 @@ def test_kili_export_labels_non_normalized_video(mocker: pytest_mock.MockerFixtu "title": "Object tracking on video", "description": "Use bounding-box to track objects across video frames.", "id": "fake_proj_id", + "dataConnections": None, } mocker.patch("kili.services.export.get_project", return_value=get_project_return_val) diff --git a/tests/unit/services/export/test_voc.py b/tests/unit/services/export/test_voc.py index 99a7cbdad..9d5335874 100644 --- a/tests/unit/services/export/test_voc.py +++ b/tests/unit/services/export/test_voc.py @@ -4,7 +4,10 @@ from kili.entrypoints.queries.label import QueriesLabel from kili.services.export.exceptions import NotCompatibleOptions -from kili.services.export.format.voc import _convert_from_kili_to_voc_format +from kili.services.export.format.voc import ( + VocExporter, + _convert_from_kili_to_voc_format, +) from tests.fakes.fake_data import asset_image_1, asset_image_1_without_annotation @@ -44,15 +47,13 @@ def test_when_exporting_to_voc_given_a_project_with_data_connection_then_it_shou "inputType": "IMAGE", "title": "", "id": "fake_proj_id", + "dataConnections": None, } mocker.patch("kili.services.export.get_project", return_value=get_project_return_val) 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 diff --git a/tests/unit/services/export/test_yolo.py b/tests/unit/services/export/test_yolo.py index 1ea561784..15fca510c 100644 --- a/tests/unit/services/export/test_yolo.py +++ b/tests/unit/services/export/test_yolo.py @@ -10,6 +10,7 @@ from kili.entrypoints.queries.label import QueriesLabel from kili.orm import Asset from kili.services.export.format.yolo import ( + YoloExporter, _convert_from_kili_to_yolo_format, _process_asset, _write_class_file, @@ -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, "_has_data_connection", return_value=False) kili = QueriesLabel() kili.api_endpoint = "https://" # type: ignore @@ -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, "_has_data_connection", return_value=False) kili = QueriesLabel() kili.api_endpoint = "https://" # type: ignore