def test_authenticated(self, client, login_user, podcast): EpisodeFactory.create_batch(3, podcast=podcast) resp = client.get(reverse("podcasts:actions", args=[podcast.id]), HTTP_TURBO_FRAME="modal") assert resp.status_code == http.HTTPStatus.OK assert resp.context_data["podcast"] == podcast assert not resp.context_data["is_subscribed"]
def test_get(self, client, podcast): EpisodeFactory.create_batch(3, podcast=podcast) RecommendationFactory.create_batch(3, podcast=podcast) resp = client.get( reverse("podcasts:podcast_recommendations", args=[podcast.id, podcast.slug])) assert resp.status_code == http.HTTPStatus.OK assert resp.context_data["podcast"] == podcast assert len(resp.context_data["recommendations"]) == 3
def test_get_podcast(self, client, podcast): EpisodeFactory.create_batch(3, podcast=podcast) resp = client.get( reverse( "podcasts:podcast_episodes", args=[podcast.id, podcast.slug], )) assert resp.status_code == http.HTTPStatus.OK assert resp.context_data["podcast"] == podcast
def test_authenticated(self, client, login_user, podcast): EpisodeFactory.create_batch(3, podcast=podcast) resp = client.get( reverse("podcasts:podcast_detail", args=[podcast.id, podcast.slug])) assert resp.status_code == http.HTTPStatus.OK assert resp.context_data["podcast"] == podcast assert resp.context_data["total_episodes"] == 3 assert not resp.context_data["is_subscribed"]
def test_get_episodes(self, client, podcast): EpisodeFactory.create_batch(3, podcast=podcast) resp = client.get( reverse( "podcasts:podcast_episodes", args=[podcast.id, podcast.slug], ), HTTP_TURBO_FRAME="episodes", ) assert resp.status_code == http.HTTPStatus.OK assert len(resp.context_data["page_obj"].object_list) == 3
def test_stats(self, client, login_user, podcast): SubscriptionFactory(podcast=podcast, user=login_user) AudioLogFactory(episode=EpisodeFactory(podcast=podcast), user=login_user) AudioLogFactory(episode=EpisodeFactory(podcast=podcast), user=login_user) AudioLogFactory(user=login_user) FavoriteFactory(user=login_user) resp = client.get(reverse("user_stats")) assert resp.status_code == http.HTTPStatus.OK assert resp.context["stats"]["subscriptions"] == 1 assert resp.context["stats"]["listened"] == 3 assert resp.context["most_listened"].count() == 2 assert resp.context["most_listened"][0] == podcast
def test_search(self, client, podcast): EpisodeFactory.create_batch(3, podcast=podcast, title="zzzz", keywords="zzzz") EpisodeFactory(title="testing", podcast=podcast) resp = client.get( reverse( "podcasts:podcast_episodes", args=[podcast.id, podcast.slug], ), {"q": "testing"}, HTTP_TURBO_FRAME="episodes", ) assert resp.status_code == http.HTTPStatus.OK assert len(resp.context_data["page_obj"].object_list) == 1
def test_parse_existing_episodes(self, mocker, clear_categories_cache): mocker.patch("requests.head", return_value=MockHeaderResponse()) mocker.patch("requests.get", return_value=MockResponse("rss_mock.txt")) podcast = PodcastFactory( rss="https://mysteriousuniverse.org/feed/podcast/", last_updated=None, pub_date=None, ) EpisodeFactory(podcast=podcast, guid="https://mysteriousuniverse.org/?p=168097") EpisodeFactory(podcast=podcast, guid="https://mysteriousuniverse.org/?p=167650") EpisodeFactory(podcast=podcast, guid="https://mysteriousuniverse.org/?p=167326") RssParser.parse_from_podcast(podcast) podcast.refresh_from_db() assert podcast.episode_set.count() == 20
def episode(podcast): return EpisodeFactory(podcast=podcast)
def episode(podcast: Podcast) -> Episode: return EpisodeFactory(podcast=podcast)