Skip to content

Commit bb9c120

Browse files
test(boxsdkgen): Add tests for automate api (box/box-codegen#943) (#1414)
1 parent 4a39dcc commit bb9c120

3 files changed

Lines changed: 71 additions & 3 deletions

File tree

‎.codegen.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{ "engineHash": "18868e7", "specHash": "f899bf6", "version": "4.7.0" }
1+
{ "engineHash": "c571efa", "specHash": "f899bf6", "version": "4.7.0" }

‎docs/box_sdk_gen/automate_workflows.md‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,11 @@ This operation is performed by calling function `get_automate_workflows_v2026_r0
1313
See the endpoint docs at
1414
[API Reference](https://developer.box.com/reference/v2026.0/get-automate-workflows/).
1515

16-
_Currently we don't have an example for calling `get_automate_workflows_v2026_r0` in integration tests_
16+
<!-- sample get_automate_workflows_v2026.0 -->
17+
18+
```python
19+
admin_client.automate_workflows.get_automate_workflows_v2026_r0(workflow_folder_id)
20+
```
1721

1822
### Arguments
1923

@@ -43,7 +47,11 @@ This operation is performed by calling function `create_automate_workflow_start_
4347
See the endpoint docs at
4448
[API Reference](https://developer.box.com/reference/v2026.0/post-automate-workflows-id-start/).
4549

46-
_Currently we don't have an example for calling `create_automate_workflow_start_v2026_r0` in integration tests_
50+
<!-- sample post_automate_workflows_id_start_v2026.0 -->
51+
52+
```python
53+
admin_client.automate_workflows.create_automate_workflow_start_v2026_r0(workflow_action.workflow.id, workflow_action.id, [workflow_file_id])
54+
```
4755

4856
### Arguments
4957

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
from box_sdk_gen.internal.utils import to_string
2+
3+
from box_sdk_gen.client import BoxClient
4+
5+
from box_sdk_gen.schemas.files import Files
6+
7+
from box_sdk_gen.managers.uploads import UploadFileAttributes
8+
9+
from box_sdk_gen.managers.uploads import UploadFileAttributesParentField
10+
11+
from box_sdk_gen.schemas.file_full import FileFull
12+
13+
from box_sdk_gen.schemas.v2026_r0.automate_workflows_v2026_r0 import (
14+
AutomateWorkflowsV2026R0,
15+
)
16+
17+
from box_sdk_gen.schemas.v2026_r0.automate_workflow_action_v2026_r0 import (
18+
AutomateWorkflowActionV2026R0,
19+
)
20+
21+
from box_sdk_gen.internal.utils import get_uuid
22+
23+
from box_sdk_gen.internal.utils import get_env_var
24+
25+
from box_sdk_gen.internal.utils import generate_byte_stream
26+
27+
from test.box_sdk_gen.test.commons import get_default_client
28+
29+
from test.box_sdk_gen.test.commons import get_default_client_with_user_subject
30+
31+
client: BoxClient = get_default_client()
32+
33+
34+
def testAutomateWorkflows():
35+
admin_client: BoxClient = get_default_client_with_user_subject(
36+
get_env_var('USER_ID')
37+
)
38+
workflow_folder_id: str = get_env_var('AUTOMATE_WORKFLOW_FOLDER_ID')
39+
uploaded_files: Files = admin_client.uploads.upload_file(
40+
UploadFileAttributes(
41+
name=get_uuid(),
42+
parent=UploadFileAttributesParentField(id=workflow_folder_id),
43+
),
44+
generate_byte_stream(1024 * 1024),
45+
)
46+
file: FileFull = uploaded_files.entries[0]
47+
workflow_file_id: str = file.id
48+
automate_workflows: AutomateWorkflowsV2026R0 = (
49+
admin_client.automate_workflows.get_automate_workflows_v2026_r0(
50+
workflow_folder_id
51+
)
52+
)
53+
assert len(automate_workflows.entries) == 1
54+
workflow_action: AutomateWorkflowActionV2026R0 = automate_workflows.entries[0]
55+
assert to_string(workflow_action.type) == 'workflow_action'
56+
assert to_string(workflow_action.action_type) == 'run_workflow'
57+
assert to_string(workflow_action.workflow.type) == 'workflow'
58+
admin_client.automate_workflows.create_automate_workflow_start_v2026_r0(
59+
workflow_action.workflow.id, workflow_action.id, [workflow_file_id]
60+
)

0 commit comments

Comments
 (0)