Skip to content

Commit

Permalink
minor test refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
mpangrazzi committed Nov 28, 2024
1 parent 5996156 commit b53c52b
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions test/dataclasses/test_chat_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ def test_with_empty_content():
message = ChatMessage.from_user("")
assert message.content == ""
assert message.text == ""
assert message.role == ChatRole.USER


def test_from_function_with_empty_name():
Expand All @@ -44,6 +45,7 @@ def test_from_function_with_empty_name():
assert message.content == content
assert message.text == content
assert message.name == ""
assert message.role == ChatRole.FUNCTION


def test_to_openai_format():
Expand Down Expand Up @@ -94,11 +96,15 @@ def test_apply_custom_chat_templating_on_chat_message():


def test_to_dict():
message = ChatMessage.from_user("content")
message.meta["some"] = "some"
content = "content"
role = "user"
meta = {"some": "some"}

message = ChatMessage.from_user(content)
message.meta.update(meta)

assert message.to_dict() == {"content": "content", "role": "user", "name": None, "meta": {"some": "some"}}
assert message.text == "content"
assert message.text == content
assert message.to_dict() == {"content": content, "role": role, "name": None, "meta": meta}


def test_from_dict():
Expand Down

0 comments on commit b53c52b

Please sign in to comment.