Skip to content

Commit

Permalink
🔧 Adiciona 'task_definition.json' ao .gitignore
Browse files Browse the repository at this point in the history
✨ (prepare.py): Adiciona a funcionalidade de salvar a resposta da definição de tarefa em 'task_definition.json'
✨ (start.py): Adiciona a funcionalidade de ler a definição de tarefa de 'task_definition.json' e usar o 'flow_definition_ref_id' para iniciar a instância de fluxo
  • Loading branch information
imakecodes committed Oct 22, 2024
1 parent a76a91c commit 00ea5a3
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
integration/task_definition.json
coverage.out
# Byte-compiled / optimized / DLL files
__pycache__/
Expand Down
4 changes: 4 additions & 0 deletions integration/commands/prepare.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
This script is used to populate the system with data for testing purposes.
It is used to create flow definitions, task definitions, and start a flow instance.
"""
import json

from utils import client


Expand Down Expand Up @@ -88,3 +90,5 @@
task_def_ref_id = response_task_definition.json()["reference_id"]

print("Task definition created: ", response_task_definition.json())
with open("task_definition.json", "w") as f:
f.write(json.dumps(response_task_definition.json(), indent=4))
12 changes: 10 additions & 2 deletions integration/commands/start.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,24 @@
"""
This script is used to start a flow instance.
"""
import os
import json

from utils import client

if not os.path.exists("task_definition.json"):
raise Exception("task_definition.json not found")

with open("task_definition.json", "r") as f:
task_definition_data = json.load(f)

flow_instance_data = {
"input_data": {
"id": 1,
},
}

flow_definition_ref_id = "f29c8333-2e2e-4690-90e1-aa86fdaa78ef"
flow_definition_ref_id = task_definition_data["flow_definition_ref_id"]

response_flow_instance = client().post(f"/flows/instances/{flow_definition_ref_id}/start", json=flow_instance_data)
assert response_flow_instance.status_code == 201

0 comments on commit 00ea5a3

Please sign in to comment.