File size: 1,769 Bytes
de65005 |
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 33 34 35 36 37 38 39 40 41 42 43 44 |
import subprocess
import time
import requests
import unittest
from app import find_top_differences_table
class TestAppFunctions(unittest.TestCase):
def setUp(self):
# Assuming that you have a ResultDataProcessor class or equivalent that provides the data
self.processor = ResultDataProcessor()
self.data = self.processor.data # Assuming this gives you the DataFrame you need
# def test_find_top_differences_table_error(self):
# # Define the variables that replicate the error
# closest_models = # define this based on your code
# exclude_columns = # define this based on your code
# selected_model_name = # define this based on your code
# # Run the problematic function without catching the TypeError
# top_differences_table, top_differences_tasks = find_top_differences_table(
# self.data, selected_model_name, closest_models, exclude_columns
# )
# If you wish to add any assertions related to the expected output, add them here
def test_streamlit_app_runs():
# Start the Streamlit app in a subprocess
process = subprocess.Popen(["streamlit", "run", "app.py"], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
# Wait for a few seconds to give Streamlit time to start
time.sleep(5)
# Make a request to the Streamlit app's default URL to check that it's running
response = requests.get('http://localhost:8501')
# Terminate the process
process.terminate()
# Check that the response from the Streamlit app was successful
assert response.status_code == 200, "Streamlit app did not start successfully"
if __name__ == '__main__':
unittest.main()
|