diff --git a/src/kili/entrypoints/client/issue.py b/src/kili/entrypoints/client/issue.py index ef1ea0d5e..5ff199eb5 100644 --- a/src/kili/entrypoints/client/issue.py +++ b/src/kili/entrypoints/client/issue.py @@ -3,12 +3,13 @@ from itertools import repeat from typing import Dict, List, Literal, Optional +import requests from typeguard import typechecked from kili.core.graphql.gateway import GraphQLGateway from kili.services.helpers import assert_all_arrays_have_same_size -from kili.services.issues import IssueUseCases -from kili.services.issues.types import IssueToCreateServiceInput +from kili.services.issue import IssueService +from kili.services.issue.types import IssueToCreateServiceInput from kili.utils.logcontext import for_all_methods, log_call @@ -17,6 +18,7 @@ class IssueEntrypoints: """Set of Issue mutations.""" graphql_gateway: GraphQLGateway + http_client: requests.Session @typechecked def create_issues( @@ -46,8 +48,8 @@ def create_issues( text_array or repeat(None), ) ] - issue_use_cases = IssueUseCases(self.graphql_gateway) - issues_entities = issue_use_cases.create_issues(project_id=project_id, issues=issues) + issue_service = IssueService(self.graphql_gateway) + issues_entities = issue_service.create_issues(project_id=project_id, issues=issues) return [{"id": issue.id} for issue in issues_entities] @typechecked @@ -71,8 +73,8 @@ def create_questions( A list of dictionary with the `id` key of the created questions. """ assert_all_arrays_have_same_size([text_array, asset_id_array]) - issue_use_cases = IssueUseCases(self.graphql_gateway) - created_questions = issue_use_cases.create_questions( + issue_service = IssueService(self.graphql_gateway) + created_questions = issue_service.create_questions( project_id, text_array, asset_id_array, asset_external_id_array ) return [{"id": question.id} for question in created_questions] diff --git a/src/kili/services/issues/__init__.py b/src/kili/services/issue/__init__.py similarity index 96% rename from src/kili/services/issues/__init__.py rename to src/kili/services/issue/__init__.py index 6e74cb0ad..3f6bb50f1 100644 --- a/src/kili/services/issues/__init__.py +++ b/src/kili/services/issue/__init__.py @@ -6,10 +6,10 @@ from kili.core.graphql.gateway.issue.types import IssueToCreateGQLGatewayInput from kili.entrypoints.mutations.asset.helpers import get_asset_ids_or_throw_error from kili.entrypoints.mutations.issue.helpers import get_labels_asset_ids_map -from kili.services.issues.types import IssueToCreateServiceInput +from kili.services.issue.types import IssueToCreateServiceInput -class IssueUseCases: +class IssueService: def __init__(self, graphql_gateway: GraphQLGateway): self._graphql_gateway = graphql_gateway diff --git a/src/kili/services/issues/types.py b/src/kili/services/issue/types.py similarity index 100% rename from src/kili/services/issues/types.py rename to src/kili/services/issue/types.py diff --git a/tests/services/test_issues.py b/tests/services/test_issues.py index 4ea8e339b..5f96dba1b 100644 --- a/tests/services/test_issues.py +++ b/tests/services/test_issues.py @@ -1,16 +1,16 @@ -from kili.services.issues import IssueUseCases -from kili.services.issues.types import IssueToCreateServiceInput +from kili.services.issue import IssueService +from kili.services.issue.types import IssueToCreateServiceInput def test_create_one_issue(graphql_gateway): - issue_use_case = IssueUseCases(graphql_gateway) + issue_service = IssueService(graphql_gateway) # given one issue to create issues = [IssueToCreateServiceInput(label_id="label_id", text="text", object_mid="object_mid")] graphql_gateway.create_issues.return_value(["issue_id"]) # when creating one issue - issues = issue_use_case.create_issues(project_id="project_id", issues=issues) + issues = issue_service.create_issues(project_id="project_id", issues=issues) # then assert issues == ["issue_id"]