See #170: include subscriptions count in channels API
This commit is contained in:
parent
46d77cec2d
commit
3674d1235d
4 changed files with 27 additions and 1 deletions
|
|
@ -90,6 +90,16 @@ def test_channel_serializer_representation(factories, to_api_date):
|
|||
assert serializers.ChannelSerializer(channel).data == expected
|
||||
|
||||
|
||||
def test_channel_serializer_representation_subscriptions_count(factories, to_api_date):
|
||||
channel = factories["audio.Channel"]()
|
||||
factories["federation.Follow"](target=channel.actor)
|
||||
factories["federation.Follow"](target=channel.actor, approved=False)
|
||||
serializer = serializers.ChannelSerializer(
|
||||
channel, context={"subscriptions_count": True}
|
||||
)
|
||||
assert serializer.data["subscriptions_count"] == 1
|
||||
|
||||
|
||||
def test_subscription_serializer(factories, to_api_date):
|
||||
subscription = factories["audio.Subscription"]()
|
||||
expected = {
|
||||
|
|
|
|||
|
|
@ -41,7 +41,9 @@ def test_channel_create(logged_in_api_client):
|
|||
def test_channel_detail(factories, logged_in_api_client):
|
||||
channel = factories["audio.Channel"](artist__description=None)
|
||||
url = reverse("api:v1:channels-detail", kwargs={"uuid": channel.uuid})
|
||||
expected = serializers.ChannelSerializer(channel).data
|
||||
expected = serializers.ChannelSerializer(
|
||||
channel, context={"subscriptions_count": True}
|
||||
).data
|
||||
response = logged_in_api_client.get(url)
|
||||
|
||||
assert response.status_code == 200
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue