Passed
Push — master ( f9ed9c...2417ae )
by Matěj
02:01
created

test_utils   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 21
dl 0
loc 29
rs 10
c 0
b 0
f 0
wmc 3

2 Functions

Rating   Name   Duplication   Size   Complexity  
A test_merge_dicts() 0 11 1
A test_required_key() 0 10 2
1
import pytest
2
3
import ssg.utils
4
5
6
def test_merge_dicts():
7
    left = {1: 2}
8
    right = {"red fish": "blue fish"}
9
    merged_expected = {1: 2, "red fish": "blue fish"}
10
    merged_actual = ssg.utils.merge_dicts(left, right)
11
12
    assert merged_actual == merged_expected
13
    assert 1 in left
14
    assert "red fish" not in left
15
    assert "red fish" in right
16
    assert 1 not in right
17
18
19
def test_required_key():
20
    rk = ssg.utils.required_key
21
    _dict = {'something': 'some_value',
22
             'something_else': 'other_value'}
23
24
    assert rk(_dict, 'something') == 'some_value'
25
    assert rk(_dict, 'something_else') == 'other_value'
26
27
    with pytest.raises(ValueError):
28
        rk(_dict, 'not-in-dict')
29