Skip to content

Commit

Permalink
tests: Add integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
frascuchon committed Jan 21, 2025
1 parent 2bddda4 commit 0340feb
Showing 1 changed file with 39 additions and 7 deletions.
46 changes: 39 additions & 7 deletions argilla/tests/integration/test_add_records.py
Original file line number Diff line number Diff line change
Expand Up @@ -569,9 +569,7 @@ def test_add_record_resources(client):
assert dataset_records[2].suggestions["topics"].score == [0.9, 0.8]


def test_add_record_with_chat_field(client):
user_id = client.users[0].id
mock_dataset_name = f"test_add_record_with_chat_field{datetime.now().strftime('%Y%m%d%H%M%S')}"
def test_add_record_with_chat_field(client: rg.Argilla, dataset_name: str):
mock_resources = [
rg.Record(
fields={
Expand Down Expand Up @@ -604,23 +602,57 @@ def test_add_record_with_chat_field(client):
]
settings = rg.Settings(
fields=[
rg.ChatField(name="chat", required=True),
rg.ChatField(name="chat", required=False),
],
questions=[
rg.TextQuestion(name="comment", use_markdown=False),
],
)
dataset = rg.Dataset(
name=mock_dataset_name,
name=dataset_name,
settings=settings,
client=client,
)
dataset.create()
dataset.records.log(records=mock_resources)
list(dataset.records)

dataset_records = list(dataset.records)
assert dataset.name == dataset_name

assert dataset.name == mock_dataset_name

def test_add_records_with_optional_chat_field(client: rg.Argilla, dataset_name: str):
mock_resources = [
rg.Record(
fields={
"text": "This a text",
"chat": None,
},
),
rg.Record(
fields={
"text": "This a text",
},
),
]
settings = rg.Settings(
fields=[
rg.TextField(name="text", required=True),
rg.ChatField(name="chat", required=False),
],
questions=[
rg.TextQuestion(name="comment", use_markdown=False),
],
)
dataset = rg.Dataset(
name=dataset_name,
settings=settings,
client=client,
)
dataset.create()
dataset.records.log(records=mock_resources)
assert len(list(dataset.records(query="this"))) == 2 # Forcing search to check the records indexation

assert dataset.name == dataset_name


def test_add_records_with_responses_and_same_schema_name(client: Argilla, username: str):
Expand Down

0 comments on commit 0340feb

Please sign in to comment.