Completed
Push — main ( 963be5...3918f7 )
by Jochen
04:19
created

tests.httpreceiver.test_message.test_from_json()   A

Complexity

Conditions 1

Size

Total Lines 18
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 13
dl 0
loc 18
rs 9.75
c 0
b 0
f 0
cc 1
nop 2
1
"""
2
:Copyright: 2007-2020 Jochen Kupperschmidt
3
:License: MIT, see LICENSE for details.
4
"""
5
6
import json
7
8
import pytest
9
10
from weitersager.httpreceiver import Message
11
12
13
@pytest.mark.parametrize(
14
    'channels, text',
15
    [
16
        (['#example'             ], 'ohai, kthxbye!'                  ),
17
        (['#partyline', '#idlers'], 'Nothing to see here, move along.'),
18
    ],
19
)
20
def test_from_json(channels, text):
21
    data = {
22
        'channels': channels,
23
        'text': text,
24
    }
25
    json_data = json.dumps(data)
26
27
    message = Message.from_json(json_data)
28
29
    assert message.channels == frozenset(channels)
30
    assert message.text == text
31