Skip to content

Commit fbd3673

Browse files
feat: deserialize folder_key on job model
1 parent 062934c commit fbd3673

File tree

5 files changed

+107
-10
lines changed

5 files changed

+107
-10
lines changed

src/uipath/platform/orchestrator/job.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,4 +78,5 @@ class Job(BaseModel):
7878
has_errors: Optional[bool] = Field(default=None, alias="HasErrors")
7979
has_warnings: Optional[bool] = Field(default=None, alias="HasWarnings")
8080
job_error: Optional[JobErrorInfo] = Field(default=None, alias="JobError")
81+
folder_key: str = Field(alias="FolderKey")
8182
id: int = Field(alias="Id")

tests/cli/test_hitl.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ async def test_read_job_trigger_successful(
164164
key=job_key,
165165
state=UiPathRuntimeStatus.SUCCESSFUL.value,
166166
output_arguments=output_args,
167+
folder_key="d0e72980-7a97-44e1-93b7-4087689521b7",
167168
)
168169
mock_retrieve_async = AsyncMock(return_value=mock_job)
169170

@@ -202,6 +203,7 @@ async def test_read_job_trigger_successful_empty_output(
202203
key=job_key,
203204
state=job_state,
204205
output_arguments="{}",
206+
folder_key="d0e72980-7a97-44e1-93b7-4087689521b7",
205207
)
206208
mock_retrieve_async = AsyncMock(return_value=mock_job)
207209

@@ -239,7 +241,11 @@ async def test_read_job_trigger_failed(
239241
job_id = 1234
240242

241243
mock_job = Job(
242-
id=job_id, key=job_key, state="Faulted", job_error=job_error_info
244+
id=job_id,
245+
key=job_key,
246+
state="Faulted",
247+
job_error=job_error_info,
248+
folder_key="d0e72980-7a97-44e1-93b7-4087689521b7",
243249
)
244250
mock_retrieve_async = AsyncMock(return_value=mock_job)
245251

@@ -281,6 +287,7 @@ async def test_read_system_agent_job_trigger_successful(
281287
key=job_key,
282288
state=UiPathRuntimeStatus.SUCCESSFUL.value,
283289
output_arguments=output_args,
290+
folder_key="d0e72980-7a97-44e1-93b7-4087689521b7",
284291
)
285292
mock_retrieve_async = AsyncMock(return_value=mock_job)
286293

@@ -875,7 +882,9 @@ async def test_create_resume_trigger_invoke_process(
875882
input_arguments={"key": "value"},
876883
)
877884

878-
mock_job = Job(id=1234, key=job_key)
885+
mock_job = Job(
886+
id=1234, key=job_key, folder_key="d0e72980-7a97-44e1-93b7-4087689521b7"
887+
)
879888
mock_invoke = AsyncMock(return_value=mock_job)
880889

881890
with patch(
@@ -904,7 +913,9 @@ async def test_create_resume_trigger_wait_job(
904913
) -> None:
905914
"""Test creating a resume trigger for WaitJob."""
906915
job_key = "test-job-key"
907-
job = Job(id=1234, key=job_key)
916+
job = Job(
917+
id=1234, key=job_key, folder_key="d0e72980-7a97-44e1-93b7-4087689521b7"
918+
)
908919
wait_job = WaitJob(job=job, process_folder_path="/test/path")
909920

910921
processor = UiPathResumeTriggerCreator()

tests/sdk/services/test_jobs_service.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ def test_retrieve(
119119
"State": "Running",
120120
"StartTime": "2024-01-01T00:00:00Z",
121121
"Id": 123,
122+
"FolderKey": "d0e72980-7a97-44e1-93b7-4087689521b7",
122123
},
123124
)
124125

@@ -129,6 +130,7 @@ def test_retrieve(
129130
assert job.state == "Running"
130131
assert job.start_time == "2024-01-01T00:00:00Z"
131132
assert job.id == 123
133+
assert job.folder_key == "d0e72980-7a97-44e1-93b7-4087689521b7"
132134

133135
sent_request = httpx_mock.get_request()
134136
assert sent_request is not None
@@ -163,6 +165,7 @@ async def test_retrieve_async(
163165
"State": "Running",
164166
"StartTime": "2024-01-01T00:00:00Z",
165167
"Id": 123,
168+
"FolderKey": "d0e72980-7a97-44e1-93b7-4087689521b7",
166169
},
167170
)
168171

@@ -173,6 +176,7 @@ async def test_retrieve_async(
173176
assert job.state == "Running"
174177
assert job.start_time == "2024-01-01T00:00:00Z"
175178
assert job.id == 123
179+
assert job.folder_key == "d0e72980-7a97-44e1-93b7-4087689521b7"
176180

177181
sent_request = httpx_mock.get_request()
178182
assert sent_request is not None
@@ -694,6 +698,7 @@ def test_extract_output_with_inline_arguments(
694698
"State": "Successful",
695699
"StartTime": "2024-01-01T00:00:00Z",
696700
"Id": 123,
701+
"FolderKey": "d0e72980-7a97-44e1-93b7-4087689521b7",
697702
"OutputArguments": '{"result": "small output data", "status": "completed"}',
698703
"OutputFile": None,
699704
}
@@ -723,6 +728,7 @@ def test_extract_output_with_attachment(
723728
"State": "Successful",
724729
"StartTime": "2024-01-01T00:00:00Z",
725730
"Id": 123,
731+
"FolderKey": "d0e72980-7a97-44e1-93b7-4087689521b7",
726732
"OutputArguments": None,
727733
"OutputFile": attachment_id,
728734
}
@@ -770,6 +776,7 @@ async def test_extract_output_async_with_inline_arguments(
770776
"State": "Successful",
771777
"StartTime": "2024-01-01T00:00:00Z",
772778
"Id": 123,
779+
"FolderKey": "d0e72980-7a97-44e1-93b7-4087689521b7",
773780
"OutputArguments": '{"result": "small output data", "status": "completed"}',
774781
"OutputFile": None,
775782
}
@@ -800,6 +807,7 @@ async def test_extract_output_async_with_attachment(
800807
"State": "Successful",
801808
"StartTime": "2024-01-01T00:00:00Z",
802809
"Id": 123,
810+
"FolderKey": "d0e72980-7a97-44e1-93b7-4087689521b7",
803811
"OutputArguments": None,
804812
"OutputFile": attachment_id,
805813
}
@@ -846,6 +854,7 @@ def test_extract_output_no_output(
846854
"State": "Successful",
847855
"StartTime": "2024-01-01T00:00:00Z",
848856
"Id": 123,
857+
"FolderKey": "d0e72980-7a97-44e1-93b7-4087689521b7",
849858
"OutputArguments": None,
850859
"OutputFile": None,
851860
}
@@ -867,6 +876,7 @@ async def test_extract_output_async_no_output(
867876
"State": "Successful",
868877
"StartTime": "2024-01-01T00:00:00Z",
869878
"Id": 123,
879+
"FolderKey": "d0e72980-7a97-44e1-93b7-4087689521b7",
870880
"OutputArguments": None,
871881
"OutputFile": None,
872882
}
@@ -913,6 +923,7 @@ def test_retrieve_job_with_large_output_integration(
913923
"StartTime": "2024-01-01T00:00:00Z",
914924
"EndTime": "2024-01-01T00:05:00Z",
915925
"Id": 456,
926+
"FolderKey": "d0e72980-7a97-44e1-93b7-4087689521b7",
916927
"OutputArguments": None, # large output is NOT stored inline
917928
"OutputFile": attachment_id, # large output IS stored as attachment
918929
"InputArguments": '{"input": "test"}', # small input stored inline
@@ -1006,6 +1017,7 @@ async def test_retrieve_job_with_large_output_integration_async(
10061017
"StartTime": "2024-01-01T00:00:00Z",
10071018
"EndTime": "2024-01-01T00:10:00Z",
10081019
"Id": 789,
1020+
"FolderKey": "d0e72980-7a97-44e1-93b7-4087689521b7",
10091021
"OutputArguments": None,
10101022
"OutputFile": attachment_id,
10111023
"InputArguments": None,
@@ -1083,6 +1095,7 @@ def test_retrieve_job_with_small_output_vs_large_output(
10831095
"State": "Successful",
10841096
"StartTime": "2024-01-01T00:00:00Z",
10851097
"Id": 100,
1098+
"FolderKey": "d0e72980-7a97-44e1-93b7-4087689521b7",
10861099
"OutputArguments": small_output, # small output stored inline
10871100
"OutputFile": None, # no attachment needed
10881101
"InputArguments": '{"input": "test"}',

tests/sdk/services/test_jobs_service_pagination.py

Lines changed: 67 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,16 @@ def test_list_returns_paged_result(
1515
"""Test that list() returns PagedResult[Job]."""
1616
httpx_mock.add_response(
1717
url=f"{base_url}{org}{tenant}/orchestrator_/odata/Jobs?%24skip=0&%24top=100",
18-
json={"value": [{"Key": "job-1", "Id": 1, "State": "Successful"}]},
18+
json={
19+
"value": [
20+
{
21+
"Key": "job-1",
22+
"Id": 1,
23+
"State": "Successful",
24+
"FolderKey": "d0e72980-7a97-44e1-93b7-4087689521b7",
25+
}
26+
]
27+
},
1928
)
2029

2130
result = jobs_service.list()
@@ -30,7 +39,15 @@ def test_list_has_more_true_when_full_page(
3039
self, jobs_service, httpx_mock, base_url, org, tenant
3140
):
3241
"""Test has_more=True when page is full."""
33-
jobs = [{"Key": f"job-{i}", "Id": i, "State": "Successful"} for i in range(100)]
42+
jobs = [
43+
{
44+
"Key": f"job-{i}",
45+
"Id": i,
46+
"State": "Successful",
47+
"FolderKey": "d0e72980-7a97-44e1-93b7-4087689521b7",
48+
}
49+
for i in range(100)
50+
]
3451
httpx_mock.add_response(
3552
url=f"{base_url}{org}{tenant}/orchestrator_/odata/Jobs?%24skip=0&%24top=100",
3653
json={"value": jobs},
@@ -45,7 +62,15 @@ def test_list_has_more_false_when_partial_page(
4562
self, jobs_service, httpx_mock, base_url, org, tenant
4663
):
4764
"""Test has_more=False when page is partial."""
48-
jobs = [{"Key": f"job-{i}", "Id": i, "State": "Successful"} for i in range(50)]
65+
jobs = [
66+
{
67+
"Key": f"job-{i}",
68+
"Id": i,
69+
"State": "Successful",
70+
"FolderKey": "d0e72980-7a97-44e1-93b7-4087689521b7",
71+
}
72+
for i in range(50)
73+
]
4974
httpx_mock.add_response(
5075
url=f"{base_url}{org}{tenant}/orchestrator_/odata/Jobs?%24skip=0&%24top=100",
5176
json={"value": jobs},
@@ -60,7 +85,16 @@ def test_list_with_filter(self, jobs_service, httpx_mock, base_url, org, tenant)
6085
"""Test list with OData filter."""
6186
httpx_mock.add_response(
6287
url=f"{base_url}{org}{tenant}/orchestrator_/odata/Jobs?%24filter=State+eq+%27Successful%27&%24skip=0&%24top=100",
63-
json={"value": [{"Key": "job-1", "Id": 1, "State": "Successful"}]},
88+
json={
89+
"value": [
90+
{
91+
"Key": "job-1",
92+
"Id": 1,
93+
"State": "Successful",
94+
"FolderKey": "d0e72980-7a97-44e1-93b7-4087689521b7",
95+
}
96+
]
97+
},
6498
)
6599

66100
result = jobs_service.list(filter="State eq 'Successful'")
@@ -75,12 +109,30 @@ def test_list_manual_pagination(
75109
# First page
76110
httpx_mock.add_response(
77111
url=f"{base_url}{org}{tenant}/orchestrator_/odata/Jobs?%24skip=0&%24top=10",
78-
json={"value": [{"Key": f"job-{i}", "Id": i} for i in range(10)]},
112+
json={
113+
"value": [
114+
{
115+
"Key": f"job-{i}",
116+
"Id": i,
117+
"FolderKey": "d0e72980-7a97-44e1-93b7-4087689521b7",
118+
}
119+
for i in range(10)
120+
]
121+
},
79122
)
80123
# Second page
81124
httpx_mock.add_response(
82125
url=f"{base_url}{org}{tenant}/orchestrator_/odata/Jobs?%24skip=10&%24top=10",
83-
json={"value": [{"Key": f"job-{i}", "Id": i} for i in range(10, 15)]},
126+
json={
127+
"value": [
128+
{
129+
"Key": f"job-{i}",
130+
"Id": i,
131+
"FolderKey": "d0e72980-7a97-44e1-93b7-4087689521b7",
132+
}
133+
for i in range(10, 15)
134+
]
135+
},
84136
)
85137

86138
# Fetch first page
@@ -152,7 +204,15 @@ async def test_list_async_returns_paged_result(
152204
"""Test that list_async() returns PagedResult[Job]."""
153205
httpx_mock.add_response(
154206
url=f"{base_url}{org}{tenant}/orchestrator_/odata/Jobs?%24skip=0&%24top=100",
155-
json={"value": [{"Key": "job-1", "Id": 1}]},
207+
json={
208+
"value": [
209+
{
210+
"Key": "job-1",
211+
"Id": 1,
212+
"FolderKey": "d0e72980-7a97-44e1-93b7-4087689521b7",
213+
}
214+
]
215+
},
156216
)
157217

158218
result = await jobs_service.list_async()

tests/sdk/services/test_processes_service.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ def test_invoke(
5050
"State": "Running",
5151
"StartTime": "2024-01-01T00:00:00Z",
5252
"Id": 123,
53+
"FolderKey": "d0e72980-7a97-44e1-93b7-4087689521b7",
5354
}
5455
]
5556
},
@@ -62,6 +63,7 @@ def test_invoke(
6263
assert job.state == "Running"
6364
assert job.start_time == "2024-01-01T00:00:00Z"
6465
assert job.id == 123
66+
assert job.folder_key == "d0e72980-7a97-44e1-93b7-4087689521b7"
6567

6668
sent_request = httpx_mock.get_request()
6769
if sent_request is None:
@@ -108,6 +110,7 @@ def test_invoke_without_input_arguments(
108110
"State": "Running",
109111
"StartTime": "2024-01-01T00:00:00Z",
110112
"Id": 123,
113+
"FolderKey": "d0e72980-7a97-44e1-93b7-4087689521b7",
111114
}
112115
]
113116
},
@@ -120,6 +123,7 @@ def test_invoke_without_input_arguments(
120123
assert job.state == "Running"
121124
assert job.start_time == "2024-01-01T00:00:00Z"
122125
assert job.id == 123
126+
assert job.folder_key == "d0e72980-7a97-44e1-93b7-4087689521b7"
123127

124128
sent_request = httpx_mock.get_request()
125129
if sent_request is None:
@@ -196,6 +200,7 @@ def test_invoke_over_10k_limit_input(
196200
"State": "Running",
197201
"StartTime": "2024-01-01T00:00:00Z",
198202
"Id": 123,
203+
"FolderKey": "d0e72980-7a97-44e1-93b7-4087689521b7",
199204
}
200205
]
201206
},
@@ -208,6 +213,7 @@ def test_invoke_over_10k_limit_input(
208213
assert job.state == "Running"
209214
assert job.start_time == "2024-01-01T00:00:00Z"
210215
assert job.id == 123
216+
assert job.folder_key == "d0e72980-7a97-44e1-93b7-4087689521b7"
211217

212218
# attachment creation, blob upload, job start
213219
requests = httpx_mock.get_requests()
@@ -265,6 +271,7 @@ async def test_invoke_async(
265271
"State": "Running",
266272
"StartTime": "2024-01-01T00:00:00Z",
267273
"Id": 123,
274+
"FolderKey": "d0e72980-7a97-44e1-93b7-4087689521b7",
268275
}
269276
]
270277
},
@@ -277,6 +284,7 @@ async def test_invoke_async(
277284
assert job.state == "Running"
278285
assert job.start_time == "2024-01-01T00:00:00Z"
279286
assert job.id == 123
287+
assert job.folder_key == "d0e72980-7a97-44e1-93b7-4087689521b7"
280288

281289
sent_request = httpx_mock.get_request()
282290
if sent_request is None:
@@ -324,6 +332,7 @@ async def test_invoke_async_without_input_arguments(
324332
"State": "Running",
325333
"StartTime": "2024-01-01T00:00:00Z",
326334
"Id": 123,
335+
"FolderKey": "d0e72980-7a97-44e1-93b7-4087689521b7",
327336
}
328337
]
329338
},
@@ -336,6 +345,7 @@ async def test_invoke_async_without_input_arguments(
336345
assert job.state == "Running"
337346
assert job.start_time == "2024-01-01T00:00:00Z"
338347
assert job.id == 123
348+
assert job.folder_key == "d0e72980-7a97-44e1-93b7-4087689521b7"
339349

340350
sent_request = httpx_mock.get_request()
341351
if sent_request is None:
@@ -413,6 +423,7 @@ async def test_invoke_async_over_10k_limit_input(
413423
"State": "Running",
414424
"StartTime": "2024-01-01T00:00:00Z",
415425
"Id": 123,
426+
"FolderKey": "d0e72980-7a97-44e1-93b7-4087689521b7",
416427
}
417428
]
418429
},
@@ -425,6 +436,7 @@ async def test_invoke_async_over_10k_limit_input(
425436
assert job.state == "Running"
426437
assert job.start_time == "2024-01-01T00:00:00Z"
427438
assert job.id == 123
439+
assert job.folder_key == "d0e72980-7a97-44e1-93b7-4087689521b7"
428440

429441
# attachment creation, blob upload, job start
430442
requests = httpx_mock.get_requests()

0 commit comments

Comments
 (0)