diff --git a/.github/workflows/cloud-run.yml b/.github/workflows/cloud-run.yml index 0ea5476..ef8df66 100644 --- a/.github/workflows/cloud-run.yml +++ b/.github/workflows/cloud-run.yml @@ -5,17 +5,17 @@ name: Cloud Run Continuous Deployment on: push: # TODO: change 'none' to 'main' to enable the workflow to run - branches: 'main' + branches: 'none' release: types: [published] env: # TODO: Paste output from setup.sh below. - PROJECT_ID: 'daniel-reyes-uprm' - SERVICE_NAME: 'study-group-finder' - SERVICE_REGION: 'us-central1' - SERVICE_ACCOUNT: '828411740843-compute@developer.gserviceaccount.com' - WORKLOAD_IDENTITY_PROVIDER: 'projects/828411740843/locations/global/workloadIdentityPools/github-provider/providers/github-project-repo' + PROJECT_ID: '' + SERVICE_NAME: '' + SERVICE_REGION: '' + SERVICE_ACCOUNT: '' + WORKLOAD_IDENTITY_PROVIDER: '' jobs: py-checks: diff --git a/app.py b/app.py index 76531e4..4e243e7 100644 --- a/app.py +++ b/app.py @@ -6,6 +6,7 @@ ############################################################################# import streamlit as st +from modules import display_user_profile, display_my_custom_component, display_post, display_genai_advice, display_recent_workouts from modules import display_my_custom_component, study_group_card, navigation_bar, display_explore_page, display_genai_advice, display_activity_summary, display_recent_workouts from data_fetcher import get_user_posts, get_genai_advice, get_user_profile, get_user_sensor_data, get_user_workouts @@ -33,6 +34,19 @@ def display_app_page(): + profile = { + "first_name": "Jane", "last_name": "Doe", + "major": "Computer Science", "year": "Junior Year", + "university": "Stanford University", "email": "jane.doe@stanford.edu", + "about_me": "Passionate about algorithms and AI...", + "focus_subjects": ["Data Structures", "Machine Learning"], + "groups_joined": 4, "study_hours": 127, "day_streak": 12, + "weekly_availability": [ + {"day": "Mon", "slots": ["9-11 AM", "2-4 PM"]}, + {"day": "Tue", "slots": ["1-3 PM"]}, + ], + } + display_user_profile(profile) # This is the starting point for your app. You do not need to change these lines if __name__ == '__main__': diff --git a/manual-deploy.sh b/manual-deploy.sh index 2e7cfb0..686fda8 100755 --- a/manual-deploy.sh +++ b/manual-deploy.sh @@ -1,6 +1,6 @@ ### VARIABLES TO CHANGE - START -PROJECT_ID=daniel-reyes-uprm -SERVICE_NAME=study-group-finder +PROJECT_ID= +SERVICE_NAME= ### VARIABLES TO CHANGE - END # ----------- Manual Deployment ------------ # diff --git a/modules.py b/modules.py index dcf7fb1..5395bc3 100644 --- a/modules.py +++ b/modules.py @@ -10,33 +10,6 @@ from internals import create_component import streamlit as st -# CSS style for modules -st.markdown(""" - -""", unsafe_allow_html=True) # Written by Chat GPT - - # This one has been written for you as an example. You may change it as wanted. def display_my_custom_component(value): """Displays a 'my custom component' which showcases an example of how custom @@ -163,9 +136,90 @@ def display_explore_page(group_list): -def display_activity_summary(workouts_list): - """Write a good docstring here.""" - pass +def display_user_profile(profile): + """ + Render the complete user profile page. + + Args + profile : dict – All profile data for the user. Expected keys: + 'first_name' : str + 'last_name' : str + 'major' : str + 'year' : str (e.g. "Junior Year") + 'university' : str + 'email' : str + 'about_me' : str + 'focus_subjects' : list[str] + 'groups_joined' : int + 'study_hours' : int + 'day_streak' : int + 'weekly_availability' : list[dict] with keys 'day' and 'slots' (list[str]) + + Example + profile = { + "first_name": "Jane", "last_name": "Doe", + "major": "Computer Science", "year": "Junior Year", + "university": "Stanford University", "email": "jane.doe@stanford.edu", + "about_me": "Passionate about algorithms and AI...", + "focus_subjects": ["Data Structures", "Machine Learning"], + "groups_joined": 4, "study_hours": 127, "day_streak": 12, + "weekly_availability": [ + {"day": "Mon", "slots": ["9-11 AM", "2-4 PM"]}, + {"day": "Tue", "slots": ["1-3 PM"]}, + ], + } + display_user_profile(profile) + """ + if not profile: + st.warning("No profile data available.") + return + + # ── Header ──────────────────────────────────────────────────────────────── + initials = (profile["first_name"][0] + profile["last_name"][0]).upper() + col_avatar, col_info, col_btns = st.columns([1, 5, 2]) + + with col_avatar: + st.markdown(f"## {initials}") + + with col_info: + st.subheader(f"{profile['first_name']} {profile['last_name']}") + st.caption(f"{profile['major']} · {profile['year']}") + st.write(f"🏛 {profile['university']} ✉ {profile['email']}") + + with col_btns: + st.button("Edit Profile", use_container_width=True) + st.button("Share Profile", use_container_width=True) + + st.divider() + + # ── About Me ────────────────────────────────────────────────────────────── + st.markdown("**ABOUT ME**") + st.write(profile["about_me"]) + + st.markdown("**FOCUS SUBJECTS**") + st.write(" ".join([f"`{s}`" for s in profile["focus_subjects"]])) + + st.divider() + + # ── Stats ───────────────────────────────────────────────────────────────── + col1, col2, col3 = st.columns(3) + col1.metric("Groups Joined", profile["groups_joined"]) + col2.metric("Study Hours", profile["study_hours"]) + col3.metric("Day Streak", profile["day_streak"]) + + st.divider() + + # ── Weekly Availability ─────────────────────────────────────────────────── + avail_col, btn_col = st.columns([4, 1]) + avail_col.markdown("**Weekly Availability**") + btn_col.button("Update Schedule", use_container_width=True) + + cols = st.columns(len(profile["weekly_availability"])) + for col, day_data in zip(cols, profile["weekly_availability"]): + with col: + st.markdown(f"**{day_data['day']}**") + for slot in day_data["slots"]: + st.caption(slot) def display_recent_workouts(workouts_list): diff --git a/modules_test.py b/modules_test.py index 497f300..f438cbf 100644 --- a/modules_test.py +++ b/modules_test.py @@ -10,11 +10,53 @@ from unittest.mock import MagicMock, patch import streamlit as st from streamlit.testing.v1 import AppTest -from modules import display_explore_page, navigation_bar, study_group_card # display_activity_summary, display_genai_advice, display_recent_workouts +from modules import display_explore_page, navigation_bar, study_group_card, display_post, display_user_profile, display_genai_advice, display_recent_workouts # Write your tests below APP_FILE = "app.py" + +class TestDisplayUserProfile(unittest.TestCase): + + def test_profile_renders_without_exception(self): + """Test that the profile page loads cleanly with no errors.""" + at = AppTest.from_file(APP_FILE).run() + + assert not at.exception + + def test_full_name_displayed(self): + """Test that the user's full name appears as a subheader.""" + at = AppTest.from_file(APP_FILE).run() + + subheader_values = [s.value for s in at.subheader] + assert any("Jane Doe" in v for v in subheader_values) + + def test_stats_display_correct_values(self): + """Test that all three stat metrics show the correct values.""" + at = AppTest.from_file(APP_FILE).run() + + metric_labels = [m.label for m in at.metric] + metric_values = [m.value for m in at.metric] + assert metric_values[metric_labels.index("Groups Joined")] == "4" + assert metric_values[metric_labels.index("Study Hours")] == "127" + assert metric_values[metric_labels.index("Day Streak")] == "12" + + def test_availability_slots_displayed(self): + """Test that time slot captions are rendered in the availability section.""" + at = AppTest.from_file(APP_FILE).run() + + caption_values = [c.value for c in at.caption] + assert any("9-11 AM" in v for v in caption_values) + assert any("1-3 PM" in v for v in caption_values) + + def test_focus_subjects_displayed(self): + """Test that focus subjects appear on the page.""" + at = AppTest.from_file(APP_FILE).run() + + all_text = " ".join([str(m.value) for m in at.markdown]) + assert "Data Structures" in all_text + assert "Machine Learning" in all_text + class TestDisplayExplorePage(unittest.TestCase): """Tests the study group app using Streamlit AppTest.""" diff --git a/setup.sh b/setup.sh index e02d122..cdc63a8 100755 --- a/setup.sh +++ b/setup.sh @@ -1,9 +1,9 @@ ### VARIABLES TO CHANGE - START -PROJECT_ID=daniel-reyes-uprm -PROJECT_NUMBER=828411740843 -SERVICE_NAME=study-group-finder -GITHUB_ORG=CodePath-Tech-Exchange-CTEx -GITHUB_REPO=code-and-conquer +PROJECT_ID= +PROJECT_NUMBER= +SERVICE_NAME= +GITHUB_ORG= +GITHUB_REPO= ### VARIABLES TO CHANGE - END # ----------- Set Up GCP Project ----------- #