from charts.utils import dict import pytest def test_safe_dict_update_error(): """Test updating a dict fails on shared keys with different values.""" with pytest.raises(Exception, match='Attempted to update dict with mismatched value.'): dict.safe_dict_update({'a': 1}, {'a': 2}) def test_safe_dict_update_same_key_value(): """Test updating a dict with a shared key and value.""" target = { 'key': 'value' } dict.safe_dict_update( target, { 'key': 'value', }, ) assert target == { 'key': 'value', } def test_safe_dict_update_new_keys(): """Test updating a dict with new keys.""" target = { 'key': 'value' } dict.safe_dict_update( target, { 'key2': 'value2', }, ) assert target == { 'key': 'value', 'key2': 'value2', }