def test_is_user_subscribed_with_not_subscribed_user(transactional_db): """Check is_user_subscribed returns False if the user is'nt subscribed.""" user = get_valid_user() user.save() podcast = get_valid_podcast_model() podcast.save() result = services.is_user_subscribed(user, podcast) assert result == False
def test_is_user_subscribed_with_subscribed_user(transactional_db): """Check is_user_subscribed returns True if the user is subscribed.""" user = get_valid_user() user.save() podcast = get_valid_podcast_model() podcast.save() user.subscription_objs.create(podcast=podcast) result = services.is_user_subscribed(user, podcast) assert result == True
def resolve_user_is_subscribed(self, args, info): if not info.request_context.user.is_authenticated(): return None return is_user_subscribed(info.request_context.user, self.instance)