File size: 1,592 Bytes
7c50fe2 c96887e |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# 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
|