Skip to content

Commit

Permalink
more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
scosman committed Sep 4, 2024
1 parent d2b1ef9 commit 62a52bb
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions libs/core/kiln_ai/datamodel/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,22 +160,28 @@ def test_task_output_schema(tmp_path):
task = Task(name="Test Task", path=path)
task.save_to_file()
assert task.output_schema() is None
task = Task(name="Test Task", output_json_schema=json_joke_schema, path=path)
task = Task(
name="Test Task",
output_json_schema=json_joke_schema,
input_json_schema=json_joke_schema,
path=path,
)
task.save_to_file()
print("asdf", task.output_json_schema)
print(task.output_schema())
schema = task.output_schema()
assert schema is not None
assert schema["properties"]["setup"]["type"] == "string"
assert schema["properties"]["punchline"]["type"] == "string"
assert schema["properties"]["rating"] is not None
schemas = [task.output_schema(), task.input_schema()]
for schema in schemas:
assert schema is not None
assert schema["properties"]["setup"]["type"] == "string"
assert schema["properties"]["punchline"]["type"] == "string"
assert schema["properties"]["rating"] is not None

# Not json schema
with pytest.raises(ValidationError):
task = Task(name="Test Task", output_json_schema="hello", path=path)
task.save_to_file()
with pytest.raises(ValidationError):
task = Task(name="Test Task", output_json_schema='{"asdf":{}}', path=path)
task.save_to_file()
with pytest.raises(ValidationError):
task = Task(name="Test Task", output_json_schema="{'asdf':{}}", path=path)
with pytest.raises(ValidationError):
task = Task(name="Test Task", input_json_schema="{asdf", path=path)

0 comments on commit 62a52bb

Please sign in to comment.