Skip to content

Commit 499cd9f

Browse files
authored
Merge pull request #57 from ks6088ts-labs/feature/issue-56_add-tests
add smoke test
2 parents 3ed09f9 + 92cde35 commit 499cd9f

File tree

5 files changed

+28
-15
lines changed

5 files changed

+28
-15
lines changed

apps/4_streamlit_chat_history/main.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,6 @@ def store_chat_history(container: ContainerProxy):
3838
pprint(response)
3939

4040

41-
# To reuse the session for Cosmos DB, just define the container globally
42-
container = get_container_client()
43-
4441
with st.sidebar:
4542
azure_openai_endpoint = st.text_input(
4643
label="AZURE_OPENAI_ENDPOINT",
@@ -116,5 +113,7 @@ def store_chat_history(container: ContainerProxy):
116113
}
117114
)
118115
# !! Here's the only difference from apps/2_streamlit_chat/main.py
119-
store_chat_history(container)
116+
store_chat_history(
117+
container=get_container_client(),
118+
)
120119
st.chat_message("assistant").write(msg)

apps/5_streamlit_query_chat_history/main.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ def get_container_client() -> ContainerProxy:
2121
)
2222

2323

24-
container = get_container_client()
25-
2624
with st.sidebar:
2725
"[Azure Portal](https://portal.azure.com/)"
2826
"[Azure OpenAI Studio](https://oai.azure.com/resource/overview)"
@@ -57,7 +55,7 @@ def convert_to_epoch(d: datetime.date) -> int:
5755
]
5856

5957
with st.spinner("Retrieving chat history. Please wait."):
60-
items = container.query_items(
58+
items = get_container_client().query_items(
6159
query=query,
6260
parameters=parameters,
6361
enable_cross_partition_query=True,

apps/8_streamlit_azure_openai_batch/main.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,6 @@
3636
"[Azure OpenAI Studio](https://oai.azure.com/resource/overview)"
3737
"[View the source code](https://github.com/ks6088ts-labs/workshop-azure-openai/blob/main/apps/8_streamlit_azure_openai_batch/main.py)"
3838

39-
client = AzureOpenAI(
40-
api_key=azure_openai_api_key,
41-
api_version=azure_openai_api_version,
42-
azure_endpoint=azure_openai_endpoint,
43-
)
44-
4539
st.title("8_streamlit_azure_openai_batch")
4640

4741
if not azure_openai_api_key or not azure_openai_endpoint or not azure_openai_api_version or not azure_openai_gpt_model:
@@ -53,6 +47,11 @@
5347
# ---------------
5448
st.header("Upload batch file")
5549
st.info("Upload a file in JSON lines format (.jsonl)")
50+
client = AzureOpenAI(
51+
api_key=azure_openai_api_key,
52+
api_version=azure_openai_api_version,
53+
azure_endpoint=azure_openai_endpoint,
54+
)
5655
uploaded_file = st.file_uploader("Upload an input file in JSON lines format", type=("jsonl"))
5756
if uploaded_file:
5857
bytes_data = uploaded_file.read()

tests/test_placeholder.py

Lines changed: 0 additions & 2 deletions
This file was deleted.

tests/test_smoke.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
from streamlit.testing.v1 import AppTest
2+
3+
4+
def test_smoke():
5+
paths = [
6+
"apps/2_streamlit_chat/main.py",
7+
"apps/4_streamlit_chat_history/main.py",
8+
"apps/5_streamlit_query_chat_history/main.py",
9+
# "apps/7_streamlit_chat_rag/main.py",
10+
"apps/8_streamlit_azure_openai_batch/main.py",
11+
"apps/99_streamlit_examples/main.py",
12+
]
13+
for path in paths:
14+
at = AppTest(
15+
script_path=path,
16+
default_timeout=60,
17+
)
18+
at.run()
19+
assert not at.exception

0 commit comments

Comments
 (0)