See #170: limit the amount of channels allowed per user
This commit is contained in:
parent
11a42e362d
commit
a3505d2099
5 changed files with 52 additions and 2 deletions
|
|
@ -23,7 +23,9 @@ def test_channel_serializer_create(factories):
|
|||
"content_category": "other",
|
||||
}
|
||||
|
||||
serializer = serializers.ChannelCreateSerializer(data=data)
|
||||
serializer = serializers.ChannelCreateSerializer(
|
||||
data=data, context={"actor": attributed_to}
|
||||
)
|
||||
assert serializer.is_valid(raise_exception=True) is True
|
||||
|
||||
channel = serializer.save(attributed_to=attributed_to)
|
||||
|
|
@ -49,6 +51,26 @@ def test_channel_serializer_create(factories):
|
|||
assert channel.library.actor == attributed_to
|
||||
|
||||
|
||||
def test_channel_serializer_create_honor_max_channels_setting(factories, preferences):
|
||||
preferences["audio__max_channels"] = 1
|
||||
attributed_to = factories["federation.Actor"](local=True)
|
||||
factories["audio.Channel"](attributed_to=attributed_to)
|
||||
data = {
|
||||
# TODO: cover
|
||||
"name": "My channel",
|
||||
"username": "mychannel",
|
||||
"description": {"text": "This is my channel", "content_type": "text/markdown"},
|
||||
"tags": ["hello", "world"],
|
||||
"content_category": "other",
|
||||
}
|
||||
|
||||
serializer = serializers.ChannelCreateSerializer(
|
||||
data=data, context={"actor": attributed_to}
|
||||
)
|
||||
with pytest.raises(serializers.serializers.ValidationError, match=r".*max.*"):
|
||||
assert serializer.is_valid(raise_exception=True)
|
||||
|
||||
|
||||
def test_channel_serializer_create_podcast(factories):
|
||||
attributed_to = factories["federation.Actor"](local=True)
|
||||
|
||||
|
|
@ -62,7 +84,9 @@ def test_channel_serializer_create_podcast(factories):
|
|||
"metadata": {"itunes_category": "Sports", "language": "en"},
|
||||
}
|
||||
|
||||
serializer = serializers.ChannelCreateSerializer(data=data)
|
||||
serializer = serializers.ChannelCreateSerializer(
|
||||
data=data, context={"actor": attributed_to}
|
||||
)
|
||||
assert serializer.is_valid(raise_exception=True) is True
|
||||
|
||||
channel = serializer.save(attributed_to=attributed_to)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue