Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added jules-scratch/verification/verification.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 23 additions & 0 deletions jules-scratch/verification/verify_podcast_display.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
from playwright.sync_api import sync_playwright, expect

def run_verification():
with sync_playwright() as p:
browser = p.chromium.launch(headless=True)
page = browser.new_page()

# Navigate to the running Flask application.
page.goto("http://127.0.0.1:5000/")

# Print the full HTML content to debug.
print(page.content())

# Expect the page to contain the podcast title and show name.
expect(page.locator("body")).to_contain_text("My Favorite Murder with Karen Kilgariff and Georgia Hardstark")

# Take a screenshot for visual verification.
page.screenshot(path="jules-scratch/verification/verification.png")

browser.close()

if __name__ == "__main__":
run_verification()
2 changes: 1 addition & 1 deletion templates/party.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ <h1>{{ item }}</h1>
<div class="center">
<form action="/toggle_playback" method="POST">
<button type="submit" class="btn">
<img class="img-fluid" src='{{ url }}'">
<img class="img-fluid" src="{{ url }}">
</button>
</form>
<form class=" form-signin" method="POST">
Expand Down
45 changes: 45 additions & 0 deletions test_app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import unittest
from unittest.mock import patch, MagicMock
from flask_app import app, db, User

class TestApp(unittest.TestCase):
def setUp(self):
app.config["TESTING"] = True
app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:///:memory:"
self.client = app.test_client()
with app.app_context():
db.create_all()

def tearDown(self):
with app.app_context():
db.session.remove()
db.drop_all()

@patch("spotipy.Spotify")
def test_party_page_with_podcast(self, mock_spotify):
# Simulate a user in the database
with app.app_context():
test_user = User(username="testuser", token="test_token")
db.session.add(test_user)
db.session.commit()

# Mock the Spotify API to return a podcast
mock_spotify_instance = MagicMock()
mock_spotify.return_value = mock_spotify_instance
mock_spotify_instance.current_playback.return_value = {
"currently_playing_type": "episode",
"item": {
"name": "Test Podcast Episode",
"images": [{"url": "http://example.com/podcast.jpg"}],
"show": {"name": "Test Podcast Show"},
},
}

# Make a request to the party page
response = self.client.get("/")
self.assertEqual(response.status_code, 200)
self.assertIn(b"Test Podcast Episode - Test Podcast Show", response.data)
self.assertIn(b"http://example.com/podcast.jpg", response.data)

if __name__ == "__main__":
unittest.main()