from programytest.client import TestClient class MyBotTests(unittest.TestCase): def setUp(self): self.client = TestClient() def test_basic_response(self): response = self.client.get_response("Hello") self.assertEqual(response, "Hi there!")
from programytest.client import TestClient class MyBotTests(unittest.TestCase): def setUp(self): self.client = TestClient() def test_aiml(self): response = self.client.get_response("What can you do?") self.assertTrue("I can tell you a joke" in response)This code sends a message to the chatbot asking what it can do, and expects the bot to respond with a list of things it can do. One of the items should be "I can tell you a joke". The test will pass if the bot gives this response. Overall, TestClient is a useful tool for writing unit tests for ProgramY chatbots. It allows developers to easily test bot responses and ensure the bot is functioning as intended.