Alysha Creelman
commited on
Adding a test file
Browse files- test_app.py +31 -0
test_app.py
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# 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
|
2 |
+
# could be put in a test.py file that test if the Chatbot is functioning.
|
3 |
+
|
4 |
+
import os
|
5 |
+
from fastapi.testclient import TestClient
|
6 |
+
import pytest
|
7 |
+
import gradio as gr
|
8 |
+
from app import respond, update_system_message, cancel_inference, demo # Import functions from app.py
|
9 |
+
|
10 |
+
client = TestClient(demo)
|
11 |
+
|
12 |
+
|
13 |
+
def test_update_system_message():
|
14 |
+
assert update_system_message("Elementary School") == (
|
15 |
+
"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."
|
16 |
+
)
|
17 |
+
assert update_system_message("Middle School") == (
|
18 |
+
"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."
|
19 |
+
)
|
20 |
+
assert update_system_message("High School") == (
|
21 |
+
"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."
|
22 |
+
)
|
23 |
+
assert update_system_message("College") == (
|
24 |
+
"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."
|
25 |
+
)
|
26 |
+
|
27 |
+
|
28 |
+
def test_cancel_inference():
|
29 |
+
global stop_inference
|
30 |
+
cancel_inference()
|
31 |
+
assert stop_inference is True
|