def test_2nd_dictionary_empty(): synonym = Hashmap(1024) antonyms = Hashmap(1024) synonym.add('fond', 'enamored') synonym.add('wrath', 'anger') assert left_join(synonym, antonyms) == [['fond', 'enamored', 'null'], ['wrath', 'anger', 'null']]
def test_simple_left_join(): synonym = Hashmap(1024) antonyms = Hashmap(1024) synonym.add('fond', 'enamored') synonym.add('wrath', 'anger') antonyms.add('fond', 'averse') assert left_join(synonym, antonyms) == [['fond', 'enamored', 'averse'], ['wrath', 'anger', 'null']]
def test_no_common_keys(): synonym = HashTable(1024) antonyms = HashTable(1024) synonym.add('fond', 'enamored') synonym.add('wrath', 'anger') antonyms.add('see', 'look') assert left_join(synonym, antonyms) == [['fond', 'enamored', 'null'], ['wrath', 'anger', 'null']]
def test_4(): dict1 = {} dict2 = { 'food': 'pizza', } expected = [] actual = left_join(dict1, dict2) assert expected == actual
def test_different_case(): d1 = {"cat": "a", "dog": "b", "Cat": "c"} d2 = {"cat": "100", "chair": "200", "Cat": "300"} assert left_join(d1, d2) == { "cat": ["a", "100"], "dog": ["b", None], "Cat": ["c", "300"] }
def test_2nd_dict_is_empty(): d1 = {"cat": "100", "chair": "200", "Cat": "300"} d2 = {} assert left_join(d1, d2) == { "cat": ["100", None], "chair": ["200", None], "Cat": ["300", None] }
def test_case1(): dict_left={ 'A':'Ramesh', 'B':'Khilan', 'C':'Chaitali', 'D':'Komal',} dict_right={ 'A':'Muffy', 'C':'Hardik', 'D':'Mufrdik', 'F':'frdik',} assert left_join(dict_left,dict_right)==[['A', 'Ramesh', 'Muffy'], ['B', 'Khilan', None], ['C', 'Chaitali', 'Hardik'], ['D', 'Komal', 'Mufrdik']]
def test_3(): dict1 = { 'anime': 'The Rising of the Shield Hero', 'song': 'bad liar', } dict2 = { 'food': 'pizza', } expected = [['anime', 'The Rising of the Shield Hero', None], ['song', 'bad liar', None]] actual = left_join(dict1, dict2) assert expected == actual
def test_lift_join_empty_dec(): ht = { 'fond': 'enamored', 'wrath': 'anger', 'diligent': 'employed', 'outift': 'garb', 'guide': 'usher' } ht1 = {} actual = left_join(ht, ht1) expected = [['fond', 'enamored', 'NULL'], ['wrath', 'anger', 'NULL'], ['diligent', 'employed', 'NULL'], ['outift', 'garb', 'NULL'], ['guide', 'usher', 'NULL']] assert actual == expected
def test_case_len(): dict_left={ 'A':'Ramesh', 'B':'Khilan', 'C':'Chaitali', 'D':'Komal',} dict_right={ 'A':'Muffy', 'C':'Hardik', 'D':'Mufrdik', 'F':'frdik',} assert len(left_join(dict_left,dict_right))==4
def test_2(): #synonym dict1 = { 'anime': 'conan', 'song': 'Natural', } #antonym dict2 = { 'anime': 'tower of god', 'food': 'pizza', } expected = [['anime', 'conan', 'tower of god'], ['song', 'Natural', None]] actual = left_join(dict1, dict2) assert expected == actual
def test_no_common_keys(my_dict): d1 = my_dict d2 = { 'car': 'averse', 'cat': 'delight', 'mouse': 'idle', 'table': 'follow', 'house': 'jam' } assert left_join(d1, d2) == { "fond": ["enamored", None], "wrath": ["anger", None], "diligent": ["employed", None], "outfit": ["garb", None], "guide": ["usher", None] }
def test_given_example(my_dict): first = my_dict second = { 'fond': 'averse', 'wrath': 'delight', 'diligent': 'idle', 'guide': 'follow', 'flow': 'jam' } assert left_join(first, second) == { "fond": ["enamored", "averse"], "wrath": ["anger", "delight"], "diligent": ["employed", "idle"], "outfit": ["garb", None], "guide": ["usher", "follow"] }
def test_lift_join(): ht = { 'fond': 'enamored', 'wrath': 'anger', 'diligent': 'employed', 'outift': 'garb', 'guide': 'usher' } ht1 = { 'fond': 'averse', 'wrath': 'delight', 'diligent': 'idle', 'guide': 'follow', 'flow': 'jam' } actual = left_join(ht, ht1) expected = [['fond', 'enamored', 'averse'], ['wrath', 'anger', 'delight'], ['diligent', 'employed', 'idle'], ['outift', 'garb', 'NULL'], ['guide', 'usher', 'follow']] assert actual == expected
def test_1(): #synonym dict1 = { 'fond': 'enamored', 'wrath': 'anger', 'diligent': 'employed', 'outfit': 'garb', 'guide': 'usher' } #antonym dict2 = { 'fond': 'averse', 'wrath': 'delight', 'diligent': 'idle', 'guide': 'follow', 'flow': 'jam' } expected = [['fond', 'enamored', 'averse'], ['wrath', 'anger', 'delight'], ['diligent', 'employed', 'idle'], ['outfit', 'garb', None], ['guide', 'usher', 'follow']] actual = left_join(dict1, dict2) assert expected == actual
def test_1st_dict_is_empty(): synonym = HashTable(1024) antonyms = HashTable(1024) antonyms.add('see', 'look') assert left_join(synonym, antonyms) == []
def test_happy_path(h1, h2): actual = left_join(h1, h2) expect = [['fond', 'enamored', 'averse'], ['wrath', 'anger', 'delight'], ['diligent', 'employed', 'idle'], ['outift', 'garb', None], ['guide', 'usher', 'follow']] assert actual == expect
def test_left_hashmap_empty(h2): actual = left_join({}, h2) expect = 'Your left hashmap is empty' assert actual == expect
def test_second_hashmap_empty(h1): actual = left_join(h1, {}) expect = [['fond', 'enamored', None], ['wrath', 'anger', None], ['diligent', 'employed', None], ['outift', 'garb', None], ['guide', 'usher', None]] assert actual == expect
def test_1st_dict_is_empty(): d1 = {} d2 = {"cat": "100", "chair": "200", "Cat": "300"} assert left_join(d1, d2) == {}
def test_empty_decs(): ht = {} ht1 = {} actual = left_join(ht, ht1) expected = [] assert actual == expected