예제 #1
0
def test_mergeduplicates_shortrows():
    table = [['foo', 'bar', 'baz'], 
             ['a', 1, True], 
             ['b', 2, True], 
             ['b', 3]]
    actual = mergeduplicates(table, 'foo')
    expect = [('foo', 'bar', 'baz'), 
              ('a', 1, True), 
              ('b', Conflict([2, 3]), True)]
    ieq(expect, actual)
예제 #2
0
def test_mergeduplicates():

    table = (('foo', 'bar', 'baz'), ('A', 1, 2), ('B', '2', None),
             ('D', 'xyz', 9.4), ('B', None, u'7.8', True), ('E', None, 42.),
             ('D', 'xyz', 12.3), ('A', 2, None))

    # value overrides missing
    result = mergeduplicates(table, 'foo', missing=None)
    expectation = (('foo', 'bar', 'baz'), ('A', Conflict([1, 2]),
                                           2), ('B', '2', u'7.8'),
                   ('D', 'xyz', Conflict([9.4, 12.3])), ('E', None, 42.))
    ieq(expectation, result)
예제 #3
0
def test_mergeduplicates_compoundkey():
    table = [
        ['foo', 'bar', 'baz'],
        ['a', 1, True],
        ['a', 1, True],
        ['a', 2, False],
        ['a', 2, None],
        ['c', 3, True],
        ['c', 3, False],
    ]
    actual = mergeduplicates(table, key=('foo', 'bar'))
    expect = [('foo', 'bar', 'baz'), ('a', 1, True), ('a', 2, False),
              ('c', 3, Conflict([True, False]))]
    ieq(expect, actual)
예제 #4
0
def test_mergeduplicates_compoundkey():
    table = [['foo', 'bar', 'baz'], 
             ['a', 1, True], 
             ['a', 1, True], 
             ['a', 2, False],
             ['a', 2, None],
             ['c', 3, True],
             ['c', 3, False],
             ]
    actual = mergeduplicates(table, key=('foo', 'bar'))
    expect = [('foo', 'bar', 'baz'), 
              ('a', 1, True), 
              ('a', 2, False), 
              ('c', 3, Conflict([True, False]))]
    ieq(expect, actual)
예제 #5
0
def test_mergeduplicates():

    table = (('foo', 'bar', 'baz'),
             ('A', 1, 2),
             ('B', '2', None),
             ('D', 'xyz', 9.4),
             ('B', None, u'7.8', True),
             ('E', None, 42.),
             ('D', 'xyz', 12.3),
             ('A', 2, None))

    # value overrides missing
    result = mergeduplicates(table, 'foo', missing=None)
    expectation = (('foo', 'bar', 'baz'),
                   ('A', Conflict([1, 2]), 2),
                   ('B', '2', u'7.8'),
                   ('D', 'xyz', Conflict([9.4, 12.3])),
                   ('E', None, 42.))
    ieq(expectation, result)
예제 #6
0
def test_mergeduplicates_empty():
    table = (('foo', 'bar'),)
    expect = (('foo', 'bar'),)
    actual = mergeduplicates(table, key='foo')
    ieq(expect, actual)
예제 #7
0
def test_mergeduplicates_shortrows():
    table = [['foo', 'bar', 'baz'], ['a', 1, True], ['b', 2, True], ['b', 3]]
    actual = mergeduplicates(table, 'foo')
    expect = [('foo', 'bar', 'baz'), ('a', 1, True),
              ('b', Conflict([2, 3]), True)]
    ieq(expect, actual)
예제 #8
0
def test_mergeduplicates_empty():
    table = (('foo', 'bar'), )
    expect = (('foo', 'bar'), )
    actual = mergeduplicates(table, key='foo')
    ieq(expect, actual)