def test_first_hashtable_empty(): h1 = Hashtable() h2 = Hashtable() h2.add('fond', 'averse') h2.add('wrath', 'delight') h2.add('diligent', 'idle') h2.add('guide', 'follow') h2.add('flow', 'jam') expected = [] actual = left_join(h1, h2) assert expected == actual
def test_no_common_keys(): d1 = { 'fond': 'enamored', 'wrath': 'anger', 'diligent': 'employed', 'outfit': 'garb', 'guide': 'usher' } d2 = {'see': 'look', 'talk': 'speak', 'yes': 'no', 'chair': 'table'} assert left_join(d1, d2) == [['fond', 'enamored', 'Null'], ['wrath', 'anger', 'Null'], ['diligent', 'employed', 'Null'], ['outfit', 'garb', 'Null'], ['guide', 'usher', 'Null']]
def test_2nd_dictionary_empty(): d1 = { 'fond': 'enamored', 'wrath': 'anger', 'diligent': 'employed', 'outfit': 'garb', 'guide': 'usher' } d2 = {} assert left_join(d1, d2) == [['fond', 'enamored', 'Null'], ['wrath', 'anger', 'Null'], ['diligent', 'employed', 'Null'], ['outfit', 'garb', 'Null'], ['guide', 'usher', 'Null']]
def test_left_join_no_matches(): h1 = Hashtable(1024) h1.add('one', 'one') h1.add('tow', 'one') h1.add('three', 'one') h1.add('four', 'one') h2 = Hashtable(1024) h2.add('six', 'tow') h2.add('seven', 'tow') h2.add('eight', 'tow') h2.add('five', 'tow') assert left_join(h1, h2) == [['rath', 'anger', None], ['pond', 'enamored', None], ['hangguide', 'usher', None], ['adiligent', 'employed', None], ['poutfit', 'garb', None]]
def test_left_join_normal(): h1 = Hashtable(1024) h1.add('one', 'one') h1.add('tow', 'one') h1.add('three', 'one') h1.add('four', 'one') h2 = Hashtable(1024) h2.add('one', 'tow') h2.add('tow', 'tow') h2.add('three', 'tow') h2.add('five', 'tow') assert left_join(h1, h2) == [['fond', 'enamored', 'averse'], ['outfit', 'garb', None], ['diligent', 'employed', 'idle'], ['wrath', 'anger', 'delight'], ['guide', 'usher', 'follow']]
def test_more_than_one_in_same_linked_list(): h1 = Hashtable() h1.add('fond', 'enamored') h1.add('fnod', 'anger') h1.add('fodn', 'employed') h1.add('donf', 'garb') h1.add('ofnd', 'usher') h2 = Hashtable() h2.add('fond', 'averse') h2.add('fnod', 'delight') h2.add('fodn', 'idle') h2.add('guide', 'follow') h2.add('flow', 'jam') expected = [['fond', 'enamored', 'averse'], ['fnod', 'anger', 'delight'], ['fodn', 'employed', 'idle'], ['donf', 'garb', None], ['ofnd', 'usher', None]] actual = left_join(h1, h2) assert expected == actual
def test_regular_way(): h1 = Hashtable() h1.add('fond', 'enamored') h1.add('wrath', 'anger') h1.add('diligent', 'employed') h1.add('outfit', 'garb') h1.add('guide', 'usher') h2 = Hashtable() h2.add('fond', 'averse') h2.add('wrath', 'delight') h2.add('diligent', 'idle') h2.add('guide', 'follow') h2.add('flow', 'jam') expected = [['wrath', 'anger', 'delight'], ['outfit', 'garb', None], ['diligent', 'employed', 'idle'], ['guide', 'usher', 'follow'], ['fond', 'enamored', 'averse']] actual = left_join(h1, h2) assert expected == actual
def test_left_join_no_matches(): one = Hashtable() one.add('pond', 'enamored') one.add('rath', 'anger') one.add('adiligent', 'employed') one.add('poutfit', 'garb') one.add('hangguide', 'usher') two = Hashtable() two.add('fond', 'averse') two.add('wrath', 'delight') two.add('diligent', 'idle') two.add('guide', 'follow') two.add('flow', 'jam') expected = [['pond', 'enamored', None], ['hangguide', 'usher', None], ['poutfit', 'garb', None], ['adiligent', 'employed', None], ['rath', 'anger', None]] actual = left_join(one, two) assert expected == actual
def test_simple_left_join(): d1 = { 'fond': 'enamored', 'wrath': 'anger', 'diligent': 'employed', 'outfit': 'garb', 'guide': 'usher' } d2 = { 'fond': 'averse', 'wrath': 'delight', 'diligent': 'idle', 'guide': 'follow', 'flow': 'jam' } assert left_join(d1, d2) == [['fond', 'enamored', 'averse'], ['wrath', 'anger', 'delight'], ['diligent', 'employed', 'idle'], ['outfit', 'garb', 'Null'], ['guide', 'usher', 'follow']]
def test_left_join_1(hashyt1, hashyt2): assert left_join(hashyt1, hashyt2) == [['fond', 'enamored', 'averse'], ['guide', 'usher', 'follow'], ['outift', 'garb', None], ['diligent', 'employed', 'idle'], ['wrath', 'anger', 'delight']]
def test_left_join_3(hashyt4, hashyt3): assert left_join(hashyt4, hashyt3) == [['flow', 'jam', None]]
def test_1st_dict_is_empty(): d1 = {} d2 = {'see': 'look', 'talk': 'speak', 'yes': 'no', 'chair': 'table'} assert left_join(d1, d2) == []