def test_left_join_only_left(ht_left):
    actual = left_join(ht_left, Hashtable())
    expected = [
        ["outfit", "garb", None],
        ["guide", "usher", None],
        ["wrath", "anger", None],
        ["diligent", "employed", None],
        ["fond", "enamored", None],
    ]
    assert actual == expected
def test_left_join_simple(ht_left, ht_right):
    actual = left_join(ht_left, ht_right)
    expected = [
        ["outfit", "garb", None],
        ["guide", "usher", "follow"],
        ["wrath", "anger", "delight"],
        ["diligent", "employed", "idle"],
        ["fond", "enamored", "averse"],
    ]

    assert actual == expected
def test_1():
    hash_1 = Hashtable(4)
    hash_1.add('key1', 'word1')
    hash_1.add('key2', 'word2')
    hash_1.add('key3', 'word3')

    hash_2 = Hashtable(4)
    hash_2.add('key1', 'word11')
    hash_2.add('key2', 'word22')
    hash_2.add('key3', 'word33')

    actual = left_join(hash_1, hash_2)
    expected = [
        ['key3', 'word3', 'word33'],
        ['key2', 'word2', 'word22'],
        ['key1', 'word1', 'word11'],
    ]
    assert actual == expected
def test_2():
    hash_1 = Hashtable(4)
    hash_1.add('key1', 'word1')
    hash_1.add('key2', 'word2')
    hash_1.add('key3', 'word3')
    hash_1.add('key4', 'word4')

    hash_2 = Hashtable(4)
    hash_2.add('key1', 'word11')
    hash_2.add('key2', 'word22')
    hash_2.add('key3', 'word33')

    actual = left_join(hash_1, hash_2)
    expected = [
        ['key3', 'word3', 'word33'],
        ['key2', 'word2', 'word22'],
        ['key1', 'word1', 'word11'],
        ['key4', 'word4', None],
    ]
    assert len(actual) == len(expected)
Exemple #5
0
def test_left_join():
    actual = left_join(key={
        'first': 'Yahya',
        'second': 'Zakaria',
        'third': 'Hasan',
        'fourth': 'Mustafa',
        'fifth': 'Mohammed',
        'sixth': 'Yaqoub'
    },
                       key2={
                           'first': 'Muhannad',
                           'second': 'Laith',
                           'third': 'Ahmad',
                           'fourth': 'Khaled',
                           'family': 'Mughrabi'
                       })
    excepted = [['first', 'Yahya', 'Muhannad'], ['second', 'Zakaria', 'Laith'],
                ['third', 'Hasan', 'Ahmad'], ['fourth', 'Mustafa', 'Khaled'],
                ['fifth', 'Mohammed', 'None'], ['sixth', 'Yaqoub', 'None']]
    assert actual == excepted
def test_left_join_both_empty():
    actual = left_join(Hashtable(), Hashtable())
    expected = []
    assert actual == expected
def test_left_join_only_right(ht_right):
    actual = left_join(Hashtable(), ht_right)
    expected = []
    assert actual == expected