Skip to content

Commit

Permalink
tests: Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
frascuchon committed Jan 25, 2023
1 parent 6e7c5d7 commit 78b41d4
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
2 changes: 2 additions & 0 deletions tests/client/test_api.py
Expand Up @@ -35,6 +35,7 @@
BaseClientError,
ForbiddenApiError,
GenericApiError,
HttpResponseError,
InputValueError,
NotFoundApiError,
UnauthorizedApiError,
Expand Down Expand Up @@ -299,6 +300,7 @@ def raise_http_error(*args, **kwargs):
(404, NotFoundApiError),
(422, ValidationApiError),
(500, GenericApiError),
(413, HttpResponseError),
],
)
def test_delete_with_errors(mocked_client, monkeypatch, status, error_type):
Expand Down
39 changes: 39 additions & 0 deletions tests/functional_tests/test_log_for_text_classification.py
Expand Up @@ -311,3 +311,42 @@ def test_dynamics_metadata(mocked_client):
ar.TextClassificationRecord(text="Another text", metadata={"b": "value"}),
name=dataset,
)


def test_log_with_bulk_error(mocked_client):

dataset = "test_log_with_bulk_error"
ar.delete(dataset)
try:
ar.log(
[
ar.TextClassificationRecord(
id=0,
text="This is an special text",
metadata={"key": 1},
),
ar.TextClassificationRecord(
id=1,
text="This is an special text",
metadata={"key": "wrong-value"},
),
],
name=dataset,
)
except BadRequestApiError as error:
assert error.ctx == {
"code": "argilla.api.errors::BulkDataError",
"params": {
"message": "Cannot log data in dataset argilla.test_log_with_bulk_error",
"errors": [
{
"reason": "failed to parse field [metadata.key] of type [long] in document with id '1'. "
"Preview of field's value: 'wrong-value'",
"caused_by": {
"type": "illegal_argument_exception",
"reason": 'For input string: "wrong-value"',
},
}
],
},
}

0 comments on commit 78b41d4

Please sign in to comment.