# This basis of this code was generated by ChatGPT. The following prompt was: I have a python script that creates a Chatbot. I want some example tests that | |
# could be put in a test.py file that test if the Chatbot is functioning. | |
import os | |
from fastapi.testclient import TestClient | |
import pytest | |
import gradio as gr | |
from app import respond, update_system_message, cancel_inference, demo # Import functions from app.py | |
client = TestClient(demo) | |
def test_update_system_message(): | |
assert update_system_message("Elementary School") == ( | |
"Your name is Wormington. You are a friendly Chatbot that can help answer questions from elementary school students. Please respond with the vocabulary that a seven-year-old can understand." | |
) | |
assert update_system_message("Middle School") == ( | |
"Your name is Wormington. You are a friendly Chatbot that can help answer questions from middle school students. Please respond at a level that middle schoolers can understand." | |
) | |
assert update_system_message("High School") == ( | |
"Your name is Wormington. You are a friendly Chatbot that can help answer questions from high school students. Please respond at a level that a high schooler can understand." | |
) | |
assert update_system_message("College") == ( | |
"Your name is Wormington. You are a friendly Chatbot that can help answer questions from college students. Please respond using very advanced, college-level vocabulary." | |
) | |
# def test_cancel_inference(): | |
# global stop_inference | |
# cancel_inference() | |
# assert stop_inference is True | |