Exemplo n.º 1
0
    def get_subscribers(self, channel_id, limit=25, offset=0, direction=DIRECTION_ASC):
        if limit > 100:
            raise TwitchAttributeException(
                'Maximum number of objects returned in one request is 100')
        if direction not in DIRECTIONS:
            raise TwitchAttributeException(
                'Direction is not valid. Valid values are {}'.format(DIRECTIONS))

        params = {
            'limit': limit,
            'offset': offset,
            'direction': direction
        }
        response = self._request_get('channels/{}/subscriptions'.format(channel_id), params=params)
        return [Subscription.construct_from(x) for x in response['subscriptions']]
Exemplo n.º 2
0
    def get_subscribers(self, channel_id, limit=25, offset=0, direction=DIRECTION_ASC):
        if limit > 100:
            raise TwitchAttributeException(
                "Maximum number of objects returned in one request is 100"
            )
        if direction not in DIRECTIONS:
            raise TwitchAttributeException(
                "Direction is not valid. Valid values are {}".format(DIRECTIONS)
            )

        params = {"limit": limit, "offset": offset, "direction": direction}
        response = self._request_get(
            "channels/{}/subscriptions".format(channel_id), params=params
        )
        return [Subscription.construct_from(x) for x in response["subscriptions"]]
Exemplo n.º 3
0
        CONF_CLIENT_ID: "1234",
        "channels": ["channel123"],
        "token": "9876",
    }
}

USER_ID = User({"id": 123, "display_name": "channel123", "logo": "logo.png"})
STREAM_OBJECT_ONLINE = Stream(
    {
        "channel": {"game": "Good Game", "status": "Title"},
        "preview": {"medium": "stream-medium.png"},
    }
)
CHANNEL_OBJECT = Channel({"followers": 42, "views": 24})
OAUTH_USER_ID = User({"id": 987})
SUB_ACTIVE = Subscription({"created_at": "2020-01-20T21:22:42", "is_gift": False})
FOLLOW_ACTIVE = Follow({"created_at": "2020-01-20T21:22:42"})


async def test_init(hass):
    """Test initial config."""

    channels = MagicMock()
    channels.get_by_id.return_value = CHANNEL_OBJECT
    streams = MagicMock()
    streams.get_stream_by_user.return_value = None

    twitch_mock = MagicMock()
    twitch_mock.users.translate_usernames_to_ids.return_value = [USER_ID]
    twitch_mock.channels = channels
    twitch_mock.streams = streams
Exemplo n.º 4
0
 def check_subscription_by_user(self, channel_id, user_id):
     response = self._request_get('channels/{}/subscriptions/{}'.format(channel_id, user_id))
     return Subscription.construct_from(response)
Exemplo n.º 5
0
 def check_subscribed_to_channel(self, user_id, channel_id):
     response = self._request_get('users/{}/subscriptions/{}'.format(
         user_id, channel_id))
     return Subscription.construct_from(response)