2013-08-02 11:37:16 -05:00
|
|
|
import unittest
|
|
|
|
|
|
2014-06-11 15:06:22 +02:00
|
|
|
import etl
|
|
|
|
|
|
2014-02-21 14:44:25 +08:00
|
|
|
|
2013-08-02 11:37:16 -05:00
|
|
|
class TransformTest(unittest.TestCase):
|
|
|
|
|
def test_transform_one_value(self):
|
2013-10-13 14:41:57 +02:00
|
|
|
old = {1: ['WORLD']}
|
|
|
|
|
expected = {'world': 1}
|
2013-08-02 11:37:16 -05:00
|
|
|
|
|
|
|
|
self.assertEqual(expected, etl.transform(old))
|
|
|
|
|
|
|
|
|
|
def test_transform_more_values(self):
|
2013-10-13 14:41:57 +02:00
|
|
|
old = {1: ['WORLD', 'GSCHOOLERS']}
|
|
|
|
|
expected = {'world': 1, 'gschoolers': 1}
|
2014-02-21 14:44:25 +08:00
|
|
|
|
2013-08-02 11:37:16 -05:00
|
|
|
self.assertEqual(expected, etl.transform(old))
|
|
|
|
|
|
|
|
|
|
def test_more_keys(self):
|
2013-10-28 00:21:52 -07:00
|
|
|
old = {1: ['APPLE', 'ARTICHOKE'], 2: ['BOAT', 'BALLERINA']}
|
2013-08-02 11:37:16 -05:00
|
|
|
expected = {
|
2013-10-13 14:41:57 +02:00
|
|
|
'apple': 1,
|
|
|
|
|
'artichoke': 1,
|
|
|
|
|
'boat': 2,
|
|
|
|
|
'ballerina': 2
|
2013-08-02 11:37:16 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
self.assertEqual(expected, etl.transform(old))
|
|
|
|
|
|
|
|
|
|
def test_full_dataset(self):
|
|
|
|
|
old = {
|
|
|
|
|
1: "AEIOULNRST",
|
|
|
|
|
2: "DG",
|
|
|
|
|
3: "BCMP",
|
|
|
|
|
4: "FHVWY",
|
|
|
|
|
5: "K",
|
|
|
|
|
8: "JX",
|
|
|
|
|
10: "QZ",
|
|
|
|
|
}
|
2014-02-21 14:44:25 +08:00
|
|
|
|
2013-08-02 11:37:16 -05:00
|
|
|
expected = {
|
2014-02-21 14:44:25 +08:00
|
|
|
"a": 1, "b": 3, "c": 3, "d": 2, "e": 1,
|
|
|
|
|
"f": 4, "g": 2, "h": 4, "i": 1, "j": 8,
|
|
|
|
|
"k": 5, "l": 1, "m": 3, "n": 1, "o": 1,
|
|
|
|
|
"p": 3, "q": 10, "r": 1, "s": 1, "t": 1,
|
|
|
|
|
"u": 1, "v": 4, "w": 4, "x": 8, "y": 4,
|
|
|
|
|
"z": 10
|
2013-08-02 11:37:16 -05:00
|
|
|
}
|
2014-02-21 14:44:25 +08:00
|
|
|
|
2013-08-02 11:37:16 -05:00
|
|
|
self.assertEqual(expected, etl.transform(old))
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
|
unittest.main()
|