Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update TaskWorkflowTemplate.create_task_workflow() method and unit test #1339

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def assign_new_summary_task_on_workflow(apps, schema_editor):
title="Workflow summarising task",
description="Workflow summarising task.",
)
TaskWorkflow.save()
task_workflow.save()


class Migration(migrations.Migration):
Expand Down
6 changes: 3 additions & 3 deletions tasks/models/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,13 @@ def get_task_templates(self) -> models.QuerySet:
)

@atomic
def create_task_workflow(self) -> "TaskWorkflow":
def create_task_workflow(self, title: str, description: str) -> "TaskWorkflow":
"""Create a workflow and it subtasks, using values from this template
workflow and its task templates."""

summary_task = Task.objects.create(title=title, description=description)
task_workflow = TaskWorkflow.objects.create(
title=self.title,
description=self.description,
summary_task=summary_task,
creator_template=self,
)

Expand Down
14 changes: 8 additions & 6 deletions tasks/tests/test_workflow_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,22 @@ def test_create_task_workflow_from_task_workflow_template(
):
"""Test creation of TaskWorkflow instances from TaskWorkflowTemplates using
its `create_task_workflow()` method."""
title = "Workflow title"
description = "Workflow description"
task_workflow = (
task_workflow_template_three_task_template_items.create_task_workflow()
task_workflow_template_three_task_template_items.create_task_workflow(
title=title,
description=description,
)
)

# Test that workflow values are valid.
assert (
task_workflow.creator_template
== task_workflow_template_three_task_template_items
)
assert task_workflow.title == task_workflow_template_three_task_template_items.title
assert (
task_workflow.description
== task_workflow_template_three_task_template_items.description
)
assert task_workflow.summary_task.title == title
assert task_workflow.summary_task.description == description
assert task_workflow.get_items().count() == 3

# Validate that item positions are equivalent.
Expand Down