Passed
Pull Request — main (#226)
by Yohann
01:32
created

test_guild.TestChannel.test_get()   B

Complexity

Conditions 1

Size

Total Lines 61
Code Lines 55

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 55
dl 0
loc 61
rs 8.4727
c 0
b 0
f 0
cc 1
nop 0

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
# Copyright Pincer 2021-Present
2
# Full MIT License can be found in `LICENSE` at the project root.
3
4
from pincer.objects import Guild, Emoji, Channel, Role
5
6
FAKE_GUILD = {
7
    'id': '0',
8
    'name': 'test-server',
9
    'features': [],
10
    'emojis': [
11
        {'name': 'test-emoji',
12
         'roles': [],
13
         'id': '0',
14
         'require_colons': True,
15
         'managed': False,
16
         'animated': False,
17
         'available': True
18
         }
19
    ],
20
    'stickers': [],
21
    'owner_id': '0',
22
    'region': 'us-east',
23
    'afk_timeout': 300,
24
    'system_channel_id': '0',
25
    'widget_enabled': False,
26
    'widget_channel_id': '0',
27
    'verification_level': 0,
28
    'roles': [
29
        {'id': '0',
30
         'name': '@everyone',
31
         'permissions': '0',
32
         'position': 0,
33
         'color': 0,
34
         'hoist': False,
35
         'managed': False,
36
         'mentionable': False,
37
         }
38
    ],
39
    'default_message_notifications': 0,
40
    'mfa_level': 0,
41
    'explicit_content_filter': 0,
42
    'max_members': 250000,
43
    'max_video_channel_users': 25,
44
    'premium_tier': 0,
45
    'premium_subscription_count': 0,
46
    'system_channel_flags': 8,
47
    'preferred_locale': 'en-US',
48
    'premium_progress_bar_enabled': False,
49
    'nsfw': False,
50
    'nsfw_level': 0,
51
    'channels':
52
    [
53
        {'id': '0',
54
         'type': 4,
55
         'name': 'Text Channels',
56
         'position': 0,
57
         'guild_id': '0',
58
         'permission_overwrites': [],
59
         'nsfw': False
60
         },
61
    ]
62
}
63
64
65
class TestChannel:
66
67
    @staticmethod
68
    def test_get():
69
70
        guild = Guild.from_dict(FAKE_GUILD)
71
72
        assert guild == Guild(
73
            id=0,
74
            name="test-server",
75
            features=[],
76
            emojis=[
77
                Emoji(
78
                    name="test-emoji",
79
                    roles=[],
80
                    id=0,
81
                    require_colons=True,
82
                    managed=False,
83
                    animated=False,
84
                    available=True
85
                )
86
            ],
87
            stickers=[],
88
            owner_id=0,
89
            region="us-east",
90
            afk_timeout=300,
91
            system_channel_id=0,
92
            widget_enabled=False,
93
            widget_channel_id=0,
94
            verification_level=0,
95
            roles=[
96
                Role(
97
                    id=0,
98
                    name="@everyone",
99
                    permissions=0,
100
                    position=0,
101
                    color=0,
102
                    hoist=False,
103
                    managed=False,
104
                    mentionable=False,
105
                )
106
            ],
107
            default_message_notifications=0,
108
            mfa_level=0,
109
            explicit_content_filter=0,
110
            max_members=250000,
111
            max_video_channel_users=25,
112
            premium_tier=0,
113
            premium_subscription_count=0,
114
            system_channel_flags=8,
115
            preferred_locale="en-US",
116
            premium_progress_bar_enabled=False,
117
            nsfw=False,
118
            nsfw_level=0,
119
            channels=[
120
                Channel(
121
                    id=0,
122
                    type=4,
123
                    name="Text Channels",
124
                    position=0,
125
                    guild_id=0,
126
                    permission_overwrites=[],
127
                    nsfw=False
128
                )
129
            ]
130
        )
131