def test_merge_or_create_key_value_for_dictionary_no_value(self): """ Test that call to merge helper method with a value of None doesn't make any changes to the dictionary that was passed in. """ dictionary = {'foo': {'key1': 'val1'}} key = 'foo' value = None base.merge_or_create_key_value_for_dictionary(dictionary, key, value) self.assertEqual( dictionary, {'foo': {'key1': 'val1'}}, "Dictionary should remain unchanged if no value was passed in to merge helper")
def test_merge_or_create_key_value_for_dictionary_key_that_does_not_exist(self): """ Test that call to merge helper method for a key that does not already exist in the dictionary that was passed in modifies the dictionary with the given key- value pair. """ dictionary = {"foo": {"key1": "val1"}} key = "baz" value = {"new": "value"} base.merge_or_create_key_value_for_dictionary(dictionary, key, value) self.assertEqual( dictionary, {"foo": {"key1": "val1"}, key: value}, "Dictionary should contain new key-value pair" )
def test_merge_or_create_key_value_for_dictionary_key_that_exists(self): """ Test that call to merge helper method for a key that already exists in the dictionary will merge the new value in with the existing value for that key. """ dictionary = {'foo': {'key1': 'val1', 'new': 'blue'}} key = 'foo' value = {'new': 'value'} base.merge_or_create_key_value_for_dictionary(dictionary, key, value) self.assertEqual( dictionary, {'foo': {'key1': 'val1', 'new': 'value'}}, "The value should have been merged into the existing key on the dictionary")
def test_merge_or_create_key_value_for_dictionary_key_that_does_not_exist(self): """ Test that call to merge helper method for a key that does not already exist in the dictionary that was passed in modifies the dictionary with the given key-value pair. """ dictionary = {'foo': {'key1': 'val1'}} key = 'baz' value = {'new': 'value'} base.merge_or_create_key_value_for_dictionary(dictionary, key, value) self.assertEqual( dictionary, {'foo': {'key1': 'val1'}, key: value}, "Dictionary should contain new key-value pair")
def test_merge_or_create_key_value_for_dictionary_no_value(self): """ Test that call to merge helper method with a value of None doesn't make any changes to the dictionary that was passed in. """ dictionary = {'foo': {'key1': 'val1'}} key = 'foo' value = None base.merge_or_create_key_value_for_dictionary(dictionary, key, value) self.assertEqual( dictionary, {'foo': { 'key1': 'val1' }}, "Dictionary should remain unchanged if no value was passed in to merge helper" )
def test_merge_or_create_key_value_for_dictionary_key_that_exists(self): """ Test that call to merge helper method for a key that already exists in the dictionary will merge the new value in with the existing value for that key. """ dictionary = {"foo": {"key1": "val1", "new": "blue"}} key = "foo" value = {"new": "value"} base.merge_or_create_key_value_for_dictionary(dictionary, key, value) self.assertEqual( dictionary, {"foo": {"key1": "val1", "new": "value"}}, "The value should have been merged into the existing key on the dictionary", )
def test_merge_or_create_key_value_for_dictionary_key_that_exists(self): """ Test that call to merge helper method for a key that already exists in the dictionary will merge the new value in with the existing value for that key. """ dictionary = {'foo': {'key1': 'val1', 'new': 'blue'}} key = 'foo' value = {'new': 'value'} base.merge_or_create_key_value_for_dictionary(dictionary, key, value) self.assertEqual( dictionary, {'foo': { 'key1': 'val1', 'new': 'value' }}, "The value should have been merged into the existing key on the dictionary" )
def test_merge_or_create_key_value_for_dictionary_key_that_does_not_exist( self): """ Test that call to merge helper method for a key that does not already exist in the dictionary that was passed in modifies the dictionary with the given key-value pair. """ dictionary = {'foo': {'key1': 'val1'}} key = 'baz' value = {'new': 'value'} base.merge_or_create_key_value_for_dictionary(dictionary, key, value) self.assertEqual(dictionary, { 'foo': { 'key1': 'val1' }, key: value }, "Dictionary should contain new key-value pair")