2018-03-25 15:24:08 +00:00
|
|
|
from funkwhale_api.activity import utils
|
|
|
|
|
|
|
|
|
|
|
|
def test_get_activity(factories):
|
2018-06-09 13:36:16 +00:00
|
|
|
user = factories["users.User"]()
|
|
|
|
listening = factories["history.Listening"]()
|
|
|
|
favorite = factories["favorites.TrackFavorite"]()
|
2018-03-25 15:24:08 +00:00
|
|
|
|
|
|
|
objects = list(utils.get_activity(user))
|
|
|
|
assert objects == [favorite, listening]
|
|
|
|
|
|
|
|
|
|
|
|
def test_get_activity_honors_privacy_level(factories, anonymous_user):
|
2018-06-10 09:27:38 +00:00
|
|
|
factories["history.Listening"](user__privacy_level="me")
|
2018-06-09 13:36:16 +00:00
|
|
|
favorite1 = factories["favorites.TrackFavorite"](user__privacy_level="everyone")
|
2018-06-10 09:27:38 +00:00
|
|
|
factories["favorites.TrackFavorite"](user__privacy_level="instance")
|
2018-03-25 15:24:08 +00:00
|
|
|
|
|
|
|
objects = list(utils.get_activity(anonymous_user))
|
|
|
|
assert objects == [favorite1]
|