-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
39 additions
and
0 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import pytest | ||
import json | ||
|
||
|
||
@pytest.fixture | ||
def load_data(): | ||
with open("function_calling_demo.jsonl", "r", encoding="utf8") as f: | ||
data_list = f.readlines() | ||
return data_list | ||
|
||
|
||
def test_data_loading(load_data): | ||
# Verify data was loaded correctly | ||
assert load_data is not None, "Data should be loaded" | ||
assert len(load_data) > 0, "Data list should not be empty" | ||
|
||
# Verify each line is a valid JSON with required fields | ||
for line in load_data: | ||
try: | ||
data = json.loads(line) | ||
assert isinstance( | ||
data, dict | ||
), "Each line should be a JSON object (dictionary)" | ||
|
||
# Check for "conversations" key | ||
assert ( | ||
"conversations" in data | ||
), "'conversations' key is missing in the JSON object" | ||
assert isinstance( | ||
data["conversations"], list | ||
), "'conversations' should be a list" | ||
|
||
# Check for 'user' and 'assistant' roles within "conversations" | ||
roles = {conv["role"] for conv in data["conversations"] if "role" in conv} | ||
assert "user" in roles, "Role 'user' is missing in conversations" | ||
assert "assistant" in roles, "Role 'assistant' is missing in conversations" | ||
|
||
except json.JSONDecodeError: | ||
pytest.fail("Each line in the data file should be valid JSON") |