Passed
Push — main ( d1c48a...9c4d1d )
by Yohann
01:52 queued 11s
created

TestDispatch.test_embed_from_dict()   A

Complexity

Conditions 1

Size

Total Lines 4
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nop 1
1
# Copyright Pincer 2021-Present
0 ignored issues
show
introduced by
Missing module docstring
Loading history...
2
# Full MIT License can be found in `LICENSE` at the project root.
3
4
from pincer.objects.message import Embed
5
6
DICT = {
7
    'title': 'Pincer - 0.6.4',
8
    'description': (
9
        '🚀 An asynchronous python API wrapper meant '
10
        'to replace discord.py\n> Snappy discord api '
11
        'wrapper written with aiohttp & websockets'
12
    ),
13
    'fields': [
14
        {
15
            'name': '**Github Repository**',
16
            'value': '> https://github.com/Pincer-org/Pincer'
17
        }
18
    ],
19
    'image': {
20
        'url': (
21
            'https://repository-images.githubusercontent.com/'
22
            '400871418/045ebf39-7c6e-4c3a-b744-0c3122374203'
23
        )
24
    },
25
    'thumbnail': {
26
        'url': 'https://pincer.dev/img/icon.png'
27
    }
28
}
29
30
EMBED = Embed(
31
    title="Pincer - 0.6.4",
32
    description=(
33
        "🚀 An asynchronous python API wrapper meant to replace"
34
        " discord.py\n> Snappy discord api wrapper written "
35
        "with aiohttp & websockets"
36
    )
37
).add_field(
38
    name="**Github Repository**",
39
    value="> https://github.com/Pincer-org/Pincer"
40
).set_thumbnail(
41
    url="https://pincer.dev/img/icon.png"
42
).set_image(
43
    url=(
44
        "https://repository-images.githubusercontent.com"
45
        "/400871418/045ebf39-7c6e-4c3a-b744-0c3122374203"
46
    )
47
)
48
49
50
def has_key_vals(actual, required):
0 ignored issues
show
introduced by
Missing function or method docstring
Loading history...
51
    return all(actual.get(key) == val for key, val in required.items())
52
53
54
class TestDispatch:
0 ignored issues
show
introduced by
Missing class docstring
Loading history...
55
56
    def test_embed_to_dict(self):
0 ignored issues
show
Coding Style introduced by
This method could be written as a function/class method.

If a method does not access any attributes of the class, it could also be implemented as a function or static method. This can help improve readability. For example

class Foo:
    def some_method(self, x, y):
        return x + y;

could be written as

class Foo:
    @classmethod
    def some_method(cls, x, y):
        return x + y;
Loading history...
57
        """
58
        Tests whether or not the dispatch class its string conversion
59
        is correct.
60
        """
61
        assert has_key_vals(EMBED.to_dict(), DICT)
62
63
    def test_embed_from_dict(self):
0 ignored issues
show
Coding Style introduced by
This method could be written as a function/class method.

If a method does not access any attributes of the class, it could also be implemented as a function or static method. This can help improve readability. For example

class Foo:
    def some_method(self, x, y):
        return x + y;

could be written as

class Foo:
    @classmethod
    def some_method(cls, x, y):
        return x + y;
Loading history...
introduced by
Missing function or method docstring
Loading history...
64
        assert has_key_vals(
65
            Embed.from_dict(DICT).to_dict(),
66
            DICT
67
        )
68