""" Test 1: Basic Streamlit App Purpose: Validate core Streamlit functionality and Container Runtime deployment """ import streamlit as st import datetime # Page configuration st.set_page_config( page_title="Spark POC - Basic Test", page_icon="đŸŽĩ", layout="wide" ) # Header st.title("đŸŽĩ Spark POC - Basic Streamlit Test") st.write("Testing core Streamlit functionality in Container Runtime environment") # Test 1.1: Basic UI Components st.header("Test 1.1: Basic UI Components") col1, col2 = st.columns(2) with col1: st.subheader("Input Components") # Text input user_name = st.text_input("Enter your name:") if user_name: st.success(f"Hello, {user_name}!") # Number input age = st.number_input("Enter your age:", min_value=0, max_value=120, value=25) st.write(f"Age: {age}") # Select box favorite_genre = st.selectbox( "Favorite music genre:", ["Pop", "Rock", "Hip-Hop", "Electronic", "Classical", "Other"] ) st.write(f"Selected: {favorite_genre}") with col2: st.subheader("Display Components") # Current time current_time = datetime.datetime.now() st.write(f"Current time: {current_time}") # Success/Error messages st.success("✅ Success message test") st.info("â„šī¸ Info message test") st.warning("âš ī¸ Warning message test") st.error("❌ Error message test") # Test 1.2: Session State st.header("Test 1.2: Session State Management") # Initialize session state if 'counter' not in st.session_state: st.session_state.counter = 0 if 'user_data' not in st.session_state: st.session_state.user_data = [] col1, col2 = st.columns(2) with col1: st.subheader("Counter Test") st.write(f"Current count: {st.session_state.counter}") if st.button("➕ Increment"): st.session_state.counter += 1 st.rerun() if st.button("➖ Decrement"): st.session_state.counter -= 1 st.rerun() if st.button("🔄 Reset"): st.session_state.counter = 0 st.rerun() with col2: st.subheader("Data Persistence Test") new_item = st.text_input("Add item to list:") if st.button("Add Item") and new_item: st.session_state.user_data.append(new_item) st.rerun() if st.session_state.user_data: st.write("Items in list:") for i, item in enumerate(st.session_state.user_data): st.write(f"{i+1}. {item}") if st.button("Clear List"): st.session_state.user_data = [] st.rerun() # Test 1.3: File Upload (if supported) st.header("Test 1.3: File Upload Capability") uploaded_file = st.file_uploader("Choose a file", type=['txt', 'csv', 'json']) if uploaded_file is not None: st.success("✅ File upload successful!") st.write(f"Filename: {uploaded_file.name}") st.write(f"File size: {uploaded_file.size} bytes") st.write(f"File type: {uploaded_file.type}") # Test 1.4: Charts and Visualization st.header("Test 1.4: Basic Charts") import pandas as pd import numpy as np # Sample data chart_data = pd.DataFrame( np.random.randn(20, 3), columns=['Song A', 'Song B', 'Song C'] ) col1, col2 = st.columns(2) with col1: st.subheader("Line Chart") st.line_chart(chart_data) with col2: st.subheader("Bar Chart") st.bar_chart(chart_data) # Test Results Summary st.header("🔍 Test Results Summary") test_results = { "UI Components": "✅ Working" if user_name else "âš ī¸ Needs interaction", "Session State": "✅ Working" if 'counter' in st.session_state else "❌ Failed", "File Upload": "✅ Working" if uploaded_file else "âš ī¸ Needs testing", "Charts": "✅ Working", "Container Runtime": "✅ App loaded successfully" } for test, status in test_results.items(): st.write(f"**{test}**: {status}") # Additional Container Runtime Information st.header("📊 Environment Information") try: import sys import platform st.write(f"**Python Version**: {sys.version}") st.write(f"**Platform**: {platform.platform()}") st.write(f"**Streamlit Version**: {st.__version__}") except Exception as e: st.error(f"Error getting environment info: {e}") # Notes section st.header("📝 Test Notes") st.text_area( "Record any observations, issues, or notable behaviors:", placeholder="Enter observations here...", height=100 )