-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(lab-3295): add tests project workflow
- Loading branch information
1 parent
369bf00
commit ceea00f
Showing
5 changed files
with
70 additions
and
12 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
src/kili/adapters/kili_api_gateway/project_workflow/operations.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import pytest_mock | ||
|
||
from kili.adapters.kili_api_gateway.kili_api_gateway import KiliAPIGateway | ||
from kili.adapters.kili_api_gateway.project_workflow.operations import ( | ||
get_update_project_workflow_mutation, | ||
) | ||
from kili.presentation.client.project_workflow import ProjectWorkflowClientMethods | ||
|
||
|
||
def test_when_updating_project_workflow_then_it_returns_updated_project_workflow( | ||
mocker: pytest_mock.MockerFixture, | ||
): | ||
kili = ProjectWorkflowClientMethods() | ||
kili.kili_api_gateway = KiliAPIGateway( | ||
graphql_client=mocker.MagicMock(), http_client=mocker.MagicMock() | ||
) | ||
# Given | ||
project_id = "fake_proj_id" | ||
|
||
# When | ||
kili.update_project_workflow(project_id, enforce_step_separation=False) | ||
|
||
# Then | ||
kili.kili_api_gateway.graphql_client.execute.assert_called_once_with( | ||
get_update_project_workflow_mutation(" enforceStepSeparation"), | ||
{ | ||
"input": {"projectId": "fake_proj_id", "enforceStepSeparation": False}, | ||
}, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
from kili.adapters.kili_api_gateway.kili_api_gateway import KiliAPIGateway | ||
from kili.adapters.kili_api_gateway.project_workflow.types import ( | ||
ProjectWorkflowDataKiliAPIGatewayInput, | ||
) | ||
from kili.domain.project import ProjectId | ||
from kili.use_cases.project_workflow import ProjectWorkflowUseCases | ||
|
||
|
||
def test_given_a_project_workflow_when_update_it_then_it_updates_project_workflow_props( | ||
kili_api_gateway: KiliAPIGateway, | ||
): | ||
# Given | ||
def mocked_update_project_workflow( | ||
project_id: ProjectId, | ||
project_workflow_data: ProjectWorkflowDataKiliAPIGatewayInput, | ||
): | ||
return { | ||
"enforce_step_separation": project_workflow_data.enforce_step_separation, | ||
"project_id": project_id, | ||
} | ||
|
||
kili_api_gateway.update_project_workflow.side_effect = mocked_update_project_workflow | ||
|
||
# When | ||
project = ProjectWorkflowUseCases(kili_api_gateway).update_project_workflow( | ||
project_id=ProjectId("fake_proj_id"), | ||
enforce_step_separation=False, | ||
) | ||
|
||
# Then | ||
assert project == {"enforce_step_separation": False, "project_id": "fake_proj_id"} |