Exemplo n.º 1
0
 def test_integration_test_from_assignment_example(self):
     hash1 = {
         'fruit': 'apples',
         'meat': 'chicken',
         'vegetables': 'potatoes',
         'drinks': ['beer', 'wine'],
         'dessert': 'ice cream'
     }
     hash2 = {
         'fruit': 'lemons',
         'meat': 'hamburger',
         'drinks': ['apple juice', 'orange juice', 'vodka']
     }
     hash3 = {
         'fruit': ['oranges', 'bananas'],
         'vegetables': ['lettuce', 'carrots'],
         'drinks': 'milk'
     }
     expected_hash = {
         'meat': ['chicken', 'hamburger'],
         'fruit': ['apples', 'lemons', 'oranges', 'bananas'],
         'vegetables': ['potatoes', 'lettuce', 'carrots'],
         'drinks':
         ['beer', 'wine', 'apple juice', 'orange juice', 'vodka', 'milk'],
         'dessert':
         'ice cream'
     }
     result = magic_hash_merge(magic_hash_merge(hash1, hash2), hash3)
     self.assertDictEqual(result, expected_hash)
Exemplo n.º 2
0
 def test_merges_unique_hashes(self):
     hash1 = {'a': 'b'}
     hash2 = {'f': 'c'}
     result = magic_hash_merge(hash1, hash2)
     self.assertDictEqual(result, {'a': 'b', 'f': 'c'})
Exemplo n.º 3
0
 def test_merges_hashes_with_repeating_keys_4(self):
     hash1 = {'a': 'b'}
     hash2 = {'a': 'c'}
     result = magic_hash_merge(hash1, hash2)
     self.assertDictEqual(result, {'a': ['b', 'c']})