-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_integration.py
50 lines (36 loc) · 1.91 KB
/
test_integration.py
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
45
46
47
48
49
50
import subprocess
import time
import requests
import unittest
from app import find_top_differences_table
from result_data_processor import ResultDataProcessor
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):
# replicating the error before fixing it
filtered_data = self.data
# Get the closest 5 models with unique indices
selected_model_name = 'Platypus2-70B-instruct'
exclude_columns=['Parameters','organization']
closest_models_diffs = filtered_data['MMLU_average'].sub(filtered_data.loc[selected_model_name, 'MMLU_average']).abs()
closest_models = closest_models_diffs.nsmallest(5, keep='first').index.drop_duplicates().tolist()
# 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
)
def test_streamlit_app_runs(self):
# 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()