Skip to content

Commit

Permalink
feat: rename uasecase into service
Browse files Browse the repository at this point in the history
  • Loading branch information
theodu committed Aug 21, 2023
1 parent 82b4f76 commit 0cf719f
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 12 deletions.
14 changes: 8 additions & 6 deletions src/kili/entrypoints/client/issue.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand All @@ -17,6 +18,7 @@ class IssueEntrypoints:
"""Set of Issue mutations."""

graphql_gateway: GraphQLGateway
http_client: requests.Session

@typechecked
def create_issues(
Expand Down Expand Up @@ -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
Expand All @@ -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]
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
File renamed without changes.
8 changes: 4 additions & 4 deletions tests/services/test_issues.py
Original file line number Diff line number Diff line change
@@ -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"]

0 comments on commit 0cf719f

Please sign in to comment.