Exemplo n.º 1
0
    def mutate_and_get_payload(cls, input, info):
        user = info.request_context.user
        if not user.is_authenticated():
            raise Exception("You need to be logged in to unsubscribe from podcasts.")

        podcast = get_podcast_by_url(input["podcast_url"])
        result = unsubscribe_user_from_podcast(user, podcast)

        return Unsubscribe(user=user, podcast=podcast, success=result)
Exemplo n.º 2
0
def test_unsubscribe_user_not_subscribed(transactional_db):
    """Test that the method still runs, but returns False when the user is not subscribed."""
    user = get_valid_user()
    user.save()
    podcast = get_valid_podcast_model()
    podcast.save()

    result = services.unsubscribe_user_from_podcast(user, podcast)

    assert result == False
Exemplo n.º 3
0
def test_unsubscribe(transactional_db):
    """Test that the user is correctly unsubscribed"""
    user = get_valid_user()
    user.save()
    podcast = get_valid_podcast_model()
    podcast.save()
    user.subscription_objs.create(podcast=podcast)

    result = services.unsubscribe_user_from_podcast(user, podcast)

    assert result == True
    assert user.subscription_objs.filter(podcast=podcast).count() == 0