Completed
Pull Request — master (#31)
by Philip
01:26
created

TestInjectNulls   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 11
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 11
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A test_inject_nulls() 0 10 1
1
import unittest
0 ignored issues
show
Coding Style introduced by
This module should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
2
3
4
from foil.records import inject_nulls, replace_keys, rename_keys
5
6
7
class TestKeyConverters(unittest.TestCase):
8
    def setUp(self):
9
        self.record = {'a': 1, 'b': 2, 'c': 3}
10
        self.key_map = {'a': 'aa', 'c': 'cc'}
11
12
    def test_rename_keys(self):
13
        expected = {'aa': 1, 'b': 2, 'cc': 3}
14
        result = rename_keys(self.record, key_map=self.key_map)
15
16
        self.assertEqual(expected, result)
17
18
    def test_replace_keys(self):
19
        expected = {'aa': 1, 'cc': 3}
20
        result = replace_keys(self.record, key_map=self.key_map)
21
22
        self.assertEqual(expected, result)
23
24
25
class TestInjectNulls(unittest.TestCase):
26
    def test_inject_nulls(self):
27
        record = {'city': 'Chicago'}
28
        record_copy = record.copy()
29
        field_names = ['city', 'state']
30
31
        expected = {'city': 'Chicago', 'state': None}
32
        result = inject_nulls(record, field_names)
33
34
        self.assertEqual(expected, result)
35
        self.assertEqual(record_copy, record)
36