コード例 #1
0
def test2():
    lst1 = ['x', 'y']
    lst2 = ['a', 'b']
    lst3 = ['x', 'y']
    lst4 = ['c', 'd']

    map_a = dict(zip(lst1, lst2))

    map_b = dict(zip(lst3, lst4))

    left_join(map_a, map_b)
    assert left_join(map_a, map_b) == [['x', 'a', 'c'], ['y', 'b', 'd']]
コード例 #2
0
def test1():
    lst1 = ['name', 'age']
    lst2 = ['doaa', '24']
    lst3 = ['name', 'age']
    lst4 = ['dana', '14']

    map_a = dict(zip(lst1, lst2))

    map_b = dict(zip(lst3, lst4))

    left_join(map_a, map_b)
    assert left_join(map_a, map_b) == [['name', 'doaa', 'dana'],
                                       ['age', '24', '14']]
コード例 #3
0
def test_function_will_account_for_all_matching():
    obj1 = {"a": "aa", "b": "bb", "c": "cc", "d": "dd", "e": "ee"}
    obj2 = {"a": "aa", "b": "bb", "c": "cc", "d": "dd", "e": "ee"}
    actual = left_join(obj1, obj2)
    expected = [["a", "aa", "aa"], ["b", "bb", "bb"], ["c", "cc", "cc"],
                ["d", "dd", "dd"], ["e", "ee", "ee"]]
    assert actual == expected
コード例 #4
0
def test_function_will_account_for_left_side_larger():
    obj1 = {"a": "aa", "b": "bb", "c": "cc", "d": "dd", "e": "ee"}
    obj2 = {"c": "cc", "v": "vv", "e": "ee"}

    actual = left_join(obj1, obj2)
    expected = [["a", "aa", None], ["b", "bb", None], ["c", "cc", "cc"],
                ["d", "dd", None], ["e", "ee", "ee"]]
    assert actual == expected
def test_all_cases(left_hash_fixture, right_hash_fixture, empty_hash_fixture):
    assert left_join(left_hash_fixture,
                     right_hash_fixture) == [['fond', 'enamored', 'averse'],
                                             ['wrath', 'anger', 'delight'],
                                             ['delight', 'employed', 'idle'],
                                             ['outfit', 'garp', 'NULL'],
                                             ['guide', 'usher', 'follow']]
    assert left_join(right_hash_fixture,
                     left_hash_fixture) == [['fond', 'averse', 'enamored'],
                                            ['wrath', 'delight', 'anger'],
                                            ['delight', 'idle', 'employed'],
                                            ['guide', 'follow', 'usher'],
                                            ['flow', 'jam', 'NULL']]
    assert left_join(left_hash_fixture,
                     empty_hash_fixture) == [['fond', 'enamored', 'NULL'],
                                             ['wrath', 'anger', 'NULL'],
                                             ['delight', 'employed', 'NULL'],
                                             ['outfit', 'garp', 'NULL'],
                                             ['guide', 'usher', 'NULL']]
    assert left_join(right_hash_fixture,
                     empty_hash_fixture) == [['fond', 'averse', 'NULL'],
                                             ['wrath', 'delight', 'NULL'],
                                             ['delight', 'idle', 'NULL'],
                                             ['guide', 'follow', 'NULL'],
                                             ['flow', 'jam', 'NULL']]
    assert left_join(empty_hash_fixture, right_hash_fixture) == []
    assert left_join(empty_hash_fixture, left_hash_fixture) == []
コード例 #6
0
def test_function_will_account_for_empty_left(hashmap1):
    actual = left_join({}, hashmap1)
    expected = []
    assert actual == expected
コード例 #7
0
def test_function_will_account_for_both_empty():
    actual = left_join({}, {})
    expected = []
    assert actual == expected
コード例 #8
0
def test_function_will_account_for_empty_right(hashmap1):
    actual = left_join(hashmap1, {})
    expected = [["a", "aa", None], ["b", "bb", None], ["c", "cc", None],
                ["d", "dd", None], ["e", "ee", None]]
    assert actual == expected