Skip to content

Commit 73f13f8

Browse files
committed
Update some contract tests
1 parent ab1db57 commit 73f13f8

File tree

3 files changed

+104
-23
lines changed

3 files changed

+104
-23
lines changed

_test_contract/platform_api/test_destinations.py

Lines changed: 43 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
from unstructured_client import UnstructuredClient
66
from unstructured_client.models import shared, operations
77
from unstructured_client.models.errors import SDKError
8-
from unstructured_client.models.shared import DestinationConnectorType
9-
108

119

1210
def test_list_destinations(
@@ -19,7 +17,14 @@ def test_list_destinations(
1917
headers={"Content-Type": "application/json"},
2018
json=[
2119
{
22-
"config": {},
20+
"config": {
21+
"remote_url": "s3://mock-s3-connector",
22+
"anonymous": False,
23+
"key": "**********",
24+
"secret": "**********",
25+
"token": None,
26+
"endpoint_url": None,
27+
},
2328
"created_at": "2025-08-22T08:47:29.802Z",
2429
"id": "0c363dec-3c70-45ee-8041-481044a6e1cc",
2530
"name": "test_destination_name",
@@ -45,7 +50,7 @@ def test_list_destinations(
4550
assert destination.id == "0c363dec-3c70-45ee-8041-481044a6e1cc"
4651
assert destination.name == "test_destination_name"
4752
assert destination.type == "s3"
48-
assert destination.config == {}
53+
assert isinstance(destination.config, shared.S3DestinationConnectorConfig)
4954
assert destination.created_at == datetime.fromisoformat(
5055
"2025-08-22T08:47:29.802+00:00"
5156
)
@@ -115,7 +120,14 @@ def test_get_destination(httpx_mock, client: UnstructuredClient, platform_api_ur
115120
method="GET",
116121
headers={"Content-Type": "application/json"},
117122
json={
118-
"config": {},
123+
"config": {
124+
"remote_url": "s3://mock-s3-connector",
125+
"anonymous": False,
126+
"key": "**********",
127+
"secret": "**********",
128+
"token": None,
129+
"endpoint_url": None,
130+
},
119131
"created_at": "2025-08-22T08:47:29.802Z",
120132
"id": "0c363dec-3c70-45ee-8041-481044a6e1cc",
121133
"name": "test_destination_name",
@@ -139,7 +151,7 @@ def test_get_destination(httpx_mock, client: UnstructuredClient, platform_api_ur
139151
assert destination.id == "0c363dec-3c70-45ee-8041-481044a6e1cc"
140152
assert destination.name == "test_destination_name"
141153
assert destination.type == "s3"
142-
assert destination.config == {}
154+
assert isinstance(destination.config, shared.S3DestinationConnectorConfig)
143155
assert destination.created_at == datetime.fromisoformat(
144156
"2025-08-22T08:47:29.802+00:00"
145157
)
@@ -178,7 +190,12 @@ def test_create_destination(
178190
method="POST",
179191
headers={"Content-Type": "application/json"},
180192
json={
181-
"config": {},
193+
"config": {
194+
"remote_url": "s3://mock-s3-connector",
195+
"key": "blah",
196+
"secret": "blah",
197+
"anonymous": False,
198+
},
182199
"created_at": "2023-09-15T01:06:53.146Z",
183200
"id": "b25d4161-77a0-4e08-b65e-86f398ce15ad",
184201
"name": "test_destination_name",
@@ -191,8 +208,12 @@ def test_create_destination(
191208
request=operations.CreateDestinationRequest(
192209
create_destination_connector=shared.CreateDestinationConnector(
193210
name="test_destination_name",
194-
type=DestinationConnectorType.S3,
195-
config={},
211+
type=shared.DestinationConnectorType.S3,
212+
config={
213+
"remote_url": "s3://mock-s3-connector",
214+
"key": "blah",
215+
"secret": "blah",
216+
},
196217
)
197218
)
198219
)
@@ -208,7 +229,7 @@ def test_create_destination(
208229
assert destination.id == "b25d4161-77a0-4e08-b65e-86f398ce15ad"
209230
assert destination.name == "test_destination_name"
210231
assert destination.type == "s3"
211-
assert destination.config == {}
232+
assert isinstance(destination.config, shared.S3DestinationConnectorConfig)
212233
assert destination.created_at == datetime.fromisoformat(
213234
"2023-09-15T01:06:53.146+00:00"
214235
)
@@ -224,7 +245,12 @@ def test_update_destination(
224245
method="PUT",
225246
headers={"Content-Type": "application/json"},
226247
json={
227-
"config": {},
248+
"config": {
249+
"remote_url": "s3://mock-s3-connector",
250+
"key": "blah",
251+
"secret": "blah",
252+
"anonymous": False,
253+
},
228254
"created_at": "2023-09-15T01:06:53.146Z",
229255
"id": "b25d4161-77a0-4e08-b65e-86f398ce15ad",
230256
"name": "test_destination_name",
@@ -237,7 +263,11 @@ def test_update_destination(
237263
request=operations.UpdateDestinationRequest(
238264
destination_id=dest_id,
239265
update_destination_connector=shared.UpdateDestinationConnector(
240-
config={}
266+
config={
267+
"remote_url": "s3://mock-s3-connector",
268+
"key": "blah",
269+
"secret": "blah",
270+
},
241271
),
242272
)
243273
)
@@ -254,7 +284,7 @@ def test_update_destination(
254284
assert updated_destination.id == "b25d4161-77a0-4e08-b65e-86f398ce15ad"
255285
assert updated_destination.name == "test_destination_name"
256286
assert updated_destination.type == "s3"
257-
assert updated_destination.config == {}
287+
assert isinstance(updated_destination.config, shared.S3DestinationConnectorConfig)
258288
assert updated_destination.created_at == datetime.fromisoformat(
259289
"2023-09-15T01:06:53.146+00:00"
260290
)

_test_contract/platform_api/test_sources.py

Lines changed: 57 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,15 @@ def test_list_sources(httpx_mock, client: UnstructuredClient, platform_api_url:
2222
headers={"Content-Type": "application/json"},
2323
json=[
2424
{
25-
"config": {},
25+
"config": {
26+
"client_id": "foo",
27+
"tenant": "foo",
28+
"authority_url": "foo",
29+
"user_pname": "foo",
30+
"client_cred": "foo",
31+
"recursive": False,
32+
"path": "foo",
33+
},
2634
"created_at": "2023-09-15T01:06:53.146Z",
2735
"id": "a15d4161-77a0-4e08-b65e-86f398ce15ad",
2836
"name": "test_source_name",
@@ -48,7 +56,7 @@ def test_list_sources(httpx_mock, client: UnstructuredClient, platform_api_url:
4856
assert source.id == "a15d4161-77a0-4e08-b65e-86f398ce15ad"
4957
assert source.name == "test_source_name"
5058
assert source.type == "onedrive"
51-
assert source.config == {}
59+
assert isinstance(source.config, shared.OneDriveSourceConnectorConfig)
5260
assert source.created_at == datetime.fromisoformat("2023-09-15T01:06:53.146+00:00")
5361

5462

@@ -114,7 +122,15 @@ def test_get_source(httpx_mock, client: UnstructuredClient, platform_api_url: st
114122
method="GET",
115123
headers={"Content-Type": "application/json"},
116124
json={
117-
"config": {},
125+
"config": {
126+
"client_id": "foo",
127+
"tenant": "foo",
128+
"authority_url": "foo",
129+
"user_pname": "foo",
130+
"client_cred": "foo",
131+
"recursive": False,
132+
"path": "foo",
133+
},
118134
"created_at": "2023-09-15T01:06:53.146Z",
119135
"id": "a15d4161-77a0-4e08-b65e-86f398ce15ad",
120136
"name": "test_source_name",
@@ -138,7 +154,7 @@ def test_get_source(httpx_mock, client: UnstructuredClient, platform_api_url: st
138154
assert source.id == "a15d4161-77a0-4e08-b65e-86f398ce15ad"
139155
assert source.name == "test_source_name"
140156
assert source.type == "onedrive"
141-
assert source.config == {}
157+
assert isinstance(source.config, shared.OneDriveSourceConnectorConfig)
142158
assert source.created_at == datetime.fromisoformat("2023-09-15T01:06:53.146+00:00")
143159

144160

@@ -171,7 +187,15 @@ def test_create_source(httpx_mock, client: UnstructuredClient, platform_api_url:
171187
method="POST",
172188
headers={"Content-Type": "application/json"},
173189
json={
174-
"config": {},
190+
"config": {
191+
"client_id": "foo",
192+
"tenant": "foo",
193+
"authority_url": "foo",
194+
"user_pname": "foo",
195+
"client_cred": "foo",
196+
"recursive": False,
197+
"path": "foo",
198+
},
175199
"created_at": "2023-09-15T01:06:53.146Z",
176200
"id": "a15d4161-77a0-4e08-b65e-86f398ce15ad",
177201
"name": "test_source_name",
@@ -185,7 +209,14 @@ def test_create_source(httpx_mock, client: UnstructuredClient, platform_api_url:
185209
create_source_connector=shared.CreateSourceConnector(
186210
name="test_source_name",
187211
type=SourceConnectorType.ONEDRIVE,
188-
config={},
212+
config={
213+
"client_id": "foo",
214+
"tenant": "foo",
215+
"authority_url": "foo",
216+
"user_pname": "foo",
217+
"client_cred": "foo",
218+
"path": "foo",
219+
},
189220
)
190221
)
191222
)
@@ -201,7 +232,7 @@ def test_create_source(httpx_mock, client: UnstructuredClient, platform_api_url:
201232
assert source.id == "a15d4161-77a0-4e08-b65e-86f398ce15ad"
202233
assert source.name == "test_source_name"
203234
assert source.type == "onedrive"
204-
assert source.config == {}
235+
assert isinstance(source.config, shared.OneDriveSourceConnectorConfig)
205236
assert source.created_at == datetime.fromisoformat("2023-09-15T01:06:53.146+00:00")
206237

207238

@@ -214,7 +245,15 @@ def test_update_source(httpx_mock, client: UnstructuredClient, platform_api_url:
214245
headers={"Content-Type": "application/json"},
215246
status_code=200,
216247
json={
217-
"config": {},
248+
"config": {
249+
"client_id": "foo",
250+
"tenant": "foo",
251+
"authority_url": "foo",
252+
"user_pname": "foo",
253+
"client_cred": "foo",
254+
"recursive": False,
255+
"path": "foo",
256+
},
218257
"created_at": "2023-09-15T01:06:53.146Z",
219258
"id": "a15d4161-77a0-4e08-b65e-86f398ce15ad",
220259
"name": "test_source_name",
@@ -227,7 +266,15 @@ def test_update_source(httpx_mock, client: UnstructuredClient, platform_api_url:
227266
request=operations.UpdateSourceRequest(
228267
source_id=dest_id,
229268
update_source_connector=shared.UpdateSourceConnector(
230-
config={}
269+
config={
270+
"client_id": "foo",
271+
"tenant": "foo",
272+
"authority_url": "foo",
273+
"user_pname": "foo",
274+
"client_cred": "foo",
275+
"recursive": False,
276+
"path": "foo",
277+
}
231278
),
232279
)
233280
)
@@ -244,7 +291,7 @@ def test_update_source(httpx_mock, client: UnstructuredClient, platform_api_url:
244291
assert updated_source.id == "a15d4161-77a0-4e08-b65e-86f398ce15ad"
245292
assert updated_source.name == "test_source_name"
246293
assert updated_source.type == "onedrive"
247-
assert updated_source.config == {}
294+
assert isinstance(updated_source.config, shared.OneDriveSourceConnectorConfig)
248295
assert updated_source.created_at == datetime.fromisoformat(
249296
"2023-09-15T01:06:53.146+00:00"
250297
)

_test_contract/platform_api/test_workflows.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ def test_list_workflows(httpx_mock, client: UnstructuredClient, platform_api_url
2525
"sources": [
2626
"f1f7b1b2-8e4b-4a2b-8f1d-3e3c7c9e5a3c",
2727
],
28+
"workflow_nodes": [],
2829
"status": "active",
2930
"workflow_type": "advanced",
3031
}
@@ -131,6 +132,7 @@ def test_create_workflow(httpx_mock, client: UnstructuredClient, platform_api_ur
131132
"sources": [
132133
"f1f7b1b2-8e4b-4a2b-8f1d-3e3c7c9e5a3c",
133134
],
135+
"workflow_nodes": [],
134136
"status": "active",
135137
"workflow_type": "advanced",
136138
},
@@ -175,6 +177,7 @@ def test_update_workflow(httpx_mock, client: UnstructuredClient, platform_api_ur
175177
"sources": [
176178
"f1f7b1b2-8e4b-4a2b-8f1d-3e3c7c9e5a3c",
177179
],
180+
"workflow_nodes": [],
178181
"status": "active",
179182
"workflow_type": "advanced",
180183
},
@@ -234,6 +237,7 @@ def test_run_workflow(httpx_mock, client: UnstructuredClient, platform_api_url:
234237
"destinations": [
235238
"aeebecc7-9d8e-4625-bf1d-815c2f084869",
236239
],
240+
"workflow_nodes": [],
237241
"status": "active",
238242
"workflow_type": "platinum",
239243
},

0 commit comments

Comments
 (0)