File: test_feature_restriction.py

package info (click to toggle)
slidge 0.3.6-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 2,544 kB
  • sloc: python: 21,794; xml: 525; sh: 57; javascript: 27; makefile: 14
file content (62 lines) | stat: -rw-r--r-- 1,785 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import pytest

from slidge.core.mixins.recipient import ReactionRecipientMixin


@pytest.mark.asyncio
async def test_no_restriction():
    x = ReactionRecipientMixin()
    assert await x.restricted_emoji_extended_feature() is None


@pytest.mark.asyncio
async def test_single_reaction_any_emoji():
    class X(ReactionRecipientMixin):
        REACTIONS_SINGLE_EMOJI = True

    x = X()
    form = await x.restricted_emoji_extended_feature()
    values = form.get_values()
    assert values["max_reactions_per_user"] == "1"
    assert values.get("allowlist") is None


@pytest.mark.asyncio
async def test_single_emoji():
    class X(ReactionRecipientMixin):
        async def available_emojis(self, legacy_msg_id=None):
            return "♥"

    x = X()
    form = await x.restricted_emoji_extended_feature()
    values = form.get_values()
    assert values.get("max_reactions_per_user") is None
    assert values.get("allowlist") == ["♥"]


@pytest.mark.asyncio
async def test_two_emojis():
    class X(ReactionRecipientMixin):
        async def available_emojis(self, legacy_msg_id=None):
            return "♥", "😛"

    x = X()
    form = await x.restricted_emoji_extended_feature()
    values = form.get_values()
    assert values.get("max_reactions_per_user") is None
    assert values.get("allowlist") == ["♥", "😛"]


@pytest.mark.asyncio
async def test_two_emojis_single_reaction():
    class X(ReactionRecipientMixin):
        REACTIONS_SINGLE_EMOJI = True

        async def available_emojis(self, legacy_msg_id=None):
            return "♥", "😛"

    x = X()
    form = await x.restricted_emoji_extended_feature()
    values = form.get_values()
    assert values.get("max_reactions_per_user") == "1"
    assert values.get("allowlist") == ["♥", "😛"]