Completed
Pull Request — master (#10)
by George
02:25
created

test_translate_error()   A

Complexity

Conditions 4

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 4
c 1
b 0
f 0
dl 0
loc 5
rs 9.2
1
# -*- coding: utf-8 -*-
2
# vi:si:et:sw=4:sts=4:ts=4
3
4
import pytest
5
6
from loafer.example.message_translator import IntMessageTranslator
7
8
9
@pytest.fixture
10
def translator():
11
    return IntMessageTranslator()
12
13
14
def test_translate(translator):
15
    for i in ['0', '-1', '1', '1000']:
16
        translated = translator.translate(i)
17
        assert 'content' in translated
18
        assert translated['content'] == int(i)
19
20
21
def test_translate_error(translator):
22
    for i in ['a', '[]', '{}', '()']:
23
        translated = translator.translate(i)
24
        assert 'content' in translated
25
        assert translated['content'] is None
26