def test_likes(mocker, mock_feeds, user, users, feeds): """ Test for: User.likes_chain User.likes_statistic """ mocker.patch("instapi.models.Feed.iter_likes", return_value=users) expected = flat([users] * len(feeds)) assert [*user.likes_chain()] == expected assert user.likes_statistic() == Counter(expected)
def test_resources(mock_feeds_with_resources, user, videos, images, feeds): """ Test for: User.iter_resources method User.resources method """ expected = flat([videos, images] * len(feeds)) assert [*user.iter_resources()] == expected assert user.resources() == expected limit = len(expected) - len(expected) // 2 assert user.resources(limit=limit) == expected[:limit]
def test_flat_dont_unpack_inner(self): assert flat([[1, [2]]]) == [1, [2]]
def test_flat_empty_iterable(self): # should work for empty list assert flat([]) == []
def test_flat_skip_empty(self): # should skip empty iterables assert flat([[1, 2, 3], [], [4, 5], [6, 7]]) == [1, 2, 3, 4, 5, 6, 7]