annotate tests/test_deduplicate.py @ 18:56596902e9ae default tip

add some setup + tests
author Jeff Hammel <k0scist@gmail.com>
date Sun, 10 Dec 2017 17:57:03 -0800
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
18
56596902e9ae add some setup + tests
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
1 #!/usr/bin/env python
56596902e9ae add some setup + tests
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
2
56596902e9ae add some setup + tests
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
3 """
56596902e9ae add some setup + tests
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
4 test deduplication
56596902e9ae add some setup + tests
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
5 """
56596902e9ae add some setup + tests
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
6
56596902e9ae add some setup + tests
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
7 import os
56596902e9ae add some setup + tests
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
8 import unittest
56596902e9ae add some setup + tests
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
9 from lemuriformes.deduplicate import deduplicate
56596902e9ae add some setup + tests
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
10
56596902e9ae add some setup + tests
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
11
56596902e9ae add some setup + tests
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
12 class TestDeduplicate(unittest.TestCase):
56596902e9ae add some setup + tests
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
13
56596902e9ae add some setup + tests
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
14 def test_deduplication(self):
56596902e9ae add some setup + tests
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
15 """basic deduplication smoketest"""
56596902e9ae add some setup + tests
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
16
56596902e9ae add some setup + tests
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
17 data = [{'a': 'B', 'c': 1, 'd': 'd'},
56596902e9ae add some setup + tests
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
18 {'a': 'a', 'c': 2, 'd': 'e'},
56596902e9ae add some setup + tests
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
19 {'a': 'F', 'c': 1, 'd': 'G'}, # duplicate!
56596902e9ae add some setup + tests
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
20 {'a': 'H', 'c': 3, 'd': 'I'},
56596902e9ae add some setup + tests
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
21 {'a': 'b', 'c': 4, 'd': 'J'}, # duplicate!
56596902e9ae add some setup + tests
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
22 {'a': 'K', 'c': 5, 'd': 'L'},
56596902e9ae add some setup + tests
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
23 ]
56596902e9ae add some setup + tests
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
24
56596902e9ae add some setup + tests
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
25 deduped = deduplicate(data)
56596902e9ae add some setup + tests
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
26 expected = [{'a': 'B', 'c': 1, 'd': 'd'},
56596902e9ae add some setup + tests
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
27 {'a': 'a', 'c': 2, 'd': 'e'},
56596902e9ae add some setup + tests
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
28 {'a': 'H', 'c': 3, 'd': 'I'},
56596902e9ae add some setup + tests
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
29 {'a': 'K', 'c': 5, 'd': 'L'},
56596902e9ae add some setup + tests
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
30 ]
56596902e9ae add some setup + tests
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
31 assert expected == deduped
56596902e9ae add some setup + tests
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
32
56596902e9ae add some setup + tests
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
33
56596902e9ae add some setup + tests
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
34 if __name__ == '__main__':
56596902e9ae add some setup + tests
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
35 unittest.main()