Skip to content

Commit d10195a

Browse files
test: Change ai and events tests to use fields instead of raw json (box/box-codegen#852) (#1088)
1 parent f63cffe commit d10195a

File tree

3 files changed

+12
-31
lines changed

3 files changed

+12
-31
lines changed

.codegen.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{ "engineHash": "504b5a7", "specHash": "62fdfd1", "version": "10.0.0" }
1+
{ "engineHash": "10c68c7", "specHash": "62fdfd1", "version": "10.0.0" }

test/ai.py

Lines changed: 10 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -328,21 +328,11 @@ def testAIExtractStructuredWithFields():
328328
],
329329
ai_agent=agent_ignoring_overriding_embeddings_model,
330330
)
331-
assert to_string(
332-
get_value_from_object_raw_data(response, 'answer.hobby')
333-
) == to_string(['guitar'])
334-
assert (
335-
to_string(get_value_from_object_raw_data(response, 'answer.firstName'))
336-
== 'John'
337-
)
338-
assert (
339-
to_string(get_value_from_object_raw_data(response, 'answer.lastName')) == 'Doe'
340-
)
341-
assert (
342-
to_string(get_value_from_object_raw_data(response, 'answer.dateOfBirth'))
343-
== '1990-07-04'
344-
)
345-
assert to_string(get_value_from_object_raw_data(response, 'answer.age')) == '34'
331+
assert to_string(response.answer.get('hobby')) == to_string(['guitar'])
332+
assert to_string(response.answer.get('firstName')) == 'John'
333+
assert to_string(response.answer.get('lastName')) == 'Doe'
334+
assert to_string(response.answer.get('dateOfBirth')) == '1990-07-04'
335+
assert to_string(response.answer.get('age')) == '34'
346336
assert response.completion_reason == 'done'
347337
client.files.delete_file_by_id(file.id)
348338

@@ -407,21 +397,11 @@ def testAIExtractStructuredWithMetadataTemplate():
407397
template_key=template_key, scope='enterprise'
408398
),
409399
)
410-
assert (
411-
to_string(get_value_from_object_raw_data(response, 'answer.firstName'))
412-
== 'John'
413-
)
414-
assert (
415-
to_string(get_value_from_object_raw_data(response, 'answer.lastName')) == 'Doe'
416-
)
417-
assert (
418-
to_string(get_value_from_object_raw_data(response, 'answer.dateOfBirth'))
419-
== '1990-07-04T00:00:00Z'
420-
)
421-
assert to_string(get_value_from_object_raw_data(response, 'answer.age')) == '34'
422-
assert to_string(
423-
get_value_from_object_raw_data(response, 'answer.hobby')
424-
) == to_string(['guitar'])
400+
assert to_string(response.answer.get('firstName')) == 'John'
401+
assert to_string(response.answer.get('lastName')) == 'Doe'
402+
assert to_string(response.answer.get('dateOfBirth')) == '1990-07-04T00:00:00Z'
403+
assert to_string(response.answer.get('age')) == '34'
404+
assert to_string(response.answer.get('hobby')) == to_string(['guitar'])
425405
assert response.completion_reason == 'done'
426406
client.metadata_templates.delete_metadata_template(
427407
DeleteMetadataTemplateScope.ENTERPRISE, template.template_key

test/events.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ def testEventUpload():
5353
assert len(events.entries) > 0
5454
first_event: Event = events.entries[0]
5555
assert to_string(first_event.event_type) == 'UPLOAD'
56+
assert to_string(first_event.additional_details.get('hash_type')) == 'sha1'
5657
source: EventSource = first_event.source
5758
assert (
5859
to_string(source.item_type) == 'file' or to_string(source.item_type) == 'folder'

0 commit comments

Comments
 (0)