Skip to content

Commit

Permalink
Update test_chat.py
Browse files Browse the repository at this point in the history
  • Loading branch information
AndresCdo committed Apr 20, 2023
1 parent ad739e0 commit 18f1efc
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions tests/unit/test_chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,23 @@


class TestChat(unittest.TestCase):
"""Test the chat functions."""
# Tests that the function returns a dictionary with the correct keys and values when valid strings are provided for role and content.
def test_happy_path_role_content(self):
"""Test that the function returns a dictionary with the correct keys and values when valid strings are provided for role and content."""
result = create_chat_message("system", "Hello, world!")
self.assertEqual(result, {"role": "system", "content": "Hello, world!"})

# Tests that the function returns a dictionary with the correct keys and values when empty strings are provided for role and content.
def test_empty_role_content(self):
"""Test that the function returns a dictionary with the correct keys and values when empty strings are provided for role and content."""
result = create_chat_message("", "")
self.assertEqual(result, {"role": "", "content": ""})

# Tests the behavior of the generate_context function when all input parameters are empty.
@patch("time.strftime")
def test_generate_context_empty_inputs(self, mock_strftime):
"""Test the behavior of the generate_context function when all input parameters are empty."""
# Mock the time.strftime function to return a fixed value
mock_strftime.return_value = "Sat Apr 15 00:00:00 2023"
# Arrange
Expand Down Expand Up @@ -52,6 +56,7 @@ def test_generate_context_empty_inputs(self, mock_strftime):

# Tests that the function successfully generates a current_context given valid inputs.
def test_generate_context_valid_inputs(self):
"""Test that the function successfully generates a current_context given valid inputs."""
# Given
prompt = "What is your favorite color?"
relevant_memory = "You once painted your room blue."
Expand Down

0 comments on commit 18f1efc

Please sign in to comment.