Passed
Push — main ( 1e0d35...60bef2 )
by
unknown
01:33
created

TestDispatch.test_string_fmt()   A

Complexity

Conditions 1

Size

Total Lines 6
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 6
rs 10
c 0
b 0
f 0
cc 1
nop 1
1
# -*- coding: utf-8 -*-
0 ignored issues
show
introduced by
Missing module docstring
Loading history...
2
# MIT License
3
#
4
# Copyright (c) 2021 Pincer
5
#
6
# Permission is hereby granted, free of charge, to any person obtaining
7
# a copy of this software and associated documentation files
8
# (the "Software"), to deal in the Software without restriction,
9
# including without limitation the rights to use, copy, modify, merge,
10
# publish, distribute, sublicense, and/or sell copies of the Software,
11
# and to permit persons to whom the Software is furnished to do so,
12
# subject to the following conditions:
13
#
14
# The above copyright notice and this permission notice shall be
15
# included in all copies or substantial portions of the Software.
16
#
17
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24
25
import unittest
26
27
from pincer.core.dispatch import GatewayDispatch
28
29
30
class TestDispatch(unittest.TestCase):
0 ignored issues
show
introduced by
Missing class docstring
Loading history...
31
    op = 123
32
    data = {
33
        "foo": "bar",
34
        "bar": "foo"
35
    }
36
    seq = 456
37
    event_name = "test_event"
38
39
    dispatch_string = '{"op": 123, "d": {"foo": "bar", "bar": "foo"}, "s": 456, "t": "test_event"}'
40
41
    dispatch = GatewayDispatch(op, data, seq, event_name)
42
43
    def test_string_fmt(self):
44
        """
45
        Tests whether or not the dispatch class its string conversion
46
        is correct.
47
        """
48
        self.assertEqual(str(self.dispatch), self.dispatch_string)
49
50
    def test_from_string(self):
51
        """
52
        Tests whether or not the from_string function is properly
53
        parsing the string and creating a GatewayDispatch instance.
54
        """
55
        self.assertEqual(
56
            str(GatewayDispatch.from_string(self.dispatch_string)),
57
            self.dispatch_string
58
        )
59
60
61
if __name__ == '__main__':
62
    unittest.main()
63