Skip to content

Commit d21cc8c

Browse files
test: Add tests for automate api (box/box-codegen#943) (#1411)
1 parent 3cfb35c commit d21cc8c

6 files changed

Lines changed: 78 additions & 5 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": "10.7.0" }
1+
{ "engineHash": "c571efa", "specHash": "f899bf6", "version": "10.7.0" }

‎.github/workflows/build-and-test-daily.yml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ jobs:
4949
SLACK_AUTOMATION_USER_ID: ${{ secrets.SLACK_AUTOMATION_USER_ID }}
5050
SLACK_ORG_ID: ${{ secrets.SLACK_ORG_ID }}
5151
SLACK_PARTNER_ITEM_ID: ${{ secrets.SLACK_PARTNER_ITEM_ID }}
52+
AUTOMATE_WORKFLOW_FOLDER_ID: ${{ secrets.AUTOMATE_WORKFLOW_FOLDER_ID }}
5253
run: |
5354
tox
5455
coverage:
@@ -90,6 +91,7 @@ jobs:
9091
SLACK_AUTOMATION_USER_ID: ${{ secrets.SLACK_AUTOMATION_USER_ID }}
9192
SLACK_ORG_ID: ${{ secrets.SLACK_ORG_ID }}
9293
SLACK_PARTNER_ITEM_ID: ${{ secrets.SLACK_PARTNER_ITEM_ID }}
94+
AUTOMATE_WORKFLOW_FOLDER_ID: ${{ secrets.AUTOMATE_WORKFLOW_FOLDER_ID }}
9395
notify:
9496
name: Send Slack Notification
9597
runs-on: ubuntu-latest

‎.github/workflows/build.yml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ jobs:
4848
SLACK_AUTOMATION_USER_ID: ${{ secrets.SLACK_AUTOMATION_USER_ID }}
4949
SLACK_ORG_ID: ${{ secrets.SLACK_ORG_ID }}
5050
SLACK_PARTNER_ITEM_ID: ${{ secrets.SLACK_PARTNER_ITEM_ID }}
51+
AUTOMATE_WORKFLOW_FOLDER_ID: ${{ secrets.AUTOMATE_WORKFLOW_FOLDER_ID }}
5152
run: |
5253
tox
5354
- name: Smoke Tests

‎docs/automate_workflows.md‎

Lines changed: 12 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,13 @@ 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(
54+
workflow_action.workflow.id, workflow_action.id, [workflow_file_id]
55+
)
56+
```
4757

4858
### Arguments
4959

‎test/automate_workflows.py‎

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.commons import get_default_client
28+
29+
from 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+
)

‎tox.ini‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ commands =
2222
pytest -n 5 {posargs} --disable-pytest-warnings --reruns 2
2323
deps = -rrequirements-test.txt
2424
allowlist_externals = pytest
25-
passenv = JWT_CONFIG_BASE_64,ADMIN_USER_ID,CLIENT_ID,CLIENT_SECRET,USER_ID,ENTERPRISE_ID,BOX_FILE_REQUEST_ID,BOX_EXTERNAL_USER_EMAIL,BOX_EXTERNAL_USER_ID,WORKFLOW_FOLDER_ID,APP_ITEM_ASSOCIATION_FILE_ID,APP_ITEM_ASSOCIATION_FOLDER_ID,APP_ITEM_SHARED_LINK,SLACK_AUTOMATION_USER_ID,SLACK_ORG_ID,SLACK_PARTNER_ITEM_ID
25+
passenv = JWT_CONFIG_BASE_64,ADMIN_USER_ID,CLIENT_ID,CLIENT_SECRET,USER_ID,ENTERPRISE_ID,BOX_FILE_REQUEST_ID,BOX_EXTERNAL_USER_EMAIL,BOX_EXTERNAL_USER_ID,WORKFLOW_FOLDER_ID,APP_ITEM_ASSOCIATION_FILE_ID,APP_ITEM_ASSOCIATION_FOLDER_ID,APP_ITEM_SHARED_LINK,SLACK_AUTOMATION_USER_ID,SLACK_ORG_ID,SLACK_PARTNER_ITEM_ID,AUTOMATE_WORKFLOW_FOLDER_ID
2626

2727
[testenv:pycodestyle]
2828
commands =
@@ -47,7 +47,7 @@ commands =
4747
deps =
4848
coverage
4949
-rrequirements-test.txt
50-
passenv = JWT_CONFIG_BASE_64,ADMIN_USER_ID,CLIENT_ID,CLIENT_SECRET,USER_ID,ENTERPRISE_ID,BOX_FILE_REQUEST_ID,BOX_EXTERNAL_USER_EMAIL,BOX_EXTERNAL_USER_ID,WORKFLOW_FOLDER_ID,APP_ITEM_ASSOCIATION_FILE_ID,APP_ITEM_ASSOCIATION_FOLDER_ID,APP_ITEM_SHARED_LINK,SLACK_AUTOMATION_USER_ID,SLACK_ORG_ID,SLACK_PARTNER_ITEM_ID
50+
passenv = JWT_CONFIG_BASE_64,ADMIN_USER_ID,CLIENT_ID,CLIENT_SECRET,USER_ID,ENTERPRISE_ID,BOX_FILE_REQUEST_ID,BOX_EXTERNAL_USER_EMAIL,BOX_EXTERNAL_USER_ID,WORKFLOW_FOLDER_ID,APP_ITEM_ASSOCIATION_FILE_ID,APP_ITEM_ASSOCIATION_FOLDER_ID,APP_ITEM_SHARED_LINK,SLACK_AUTOMATION_USER_ID,SLACK_ORG_ID,SLACK_PARTNER_ITEM_ID,AUTOMATE_WORKFLOW_FOLDER_ID
5151

5252
[testenv:py311-build]
5353
description = Build the source and binary wheel packages for distribution.

0 commit comments

Comments
 (0)