def test_assert_dict_subset_subset(): """Test that assert_dict_subset correctly identifies expected as a subset of actual.""" actual = { "key": "value", "key2": "value2", "parent_key": { "nested_key": "nested_value", "nested_key2": "nested_value2" }, } expected = {"key": "value", "parent_key": {"nested_key": "nested_value"}} # Expected being a subset should result in no differences assert _assert_dict_subset(actual, expected) == {}
def test_assert_dict_subset_subset(): """Test that assert_dict_subset correctly identifies expected as a subset of actual.""" actual = { 'key': 'value', 'key2': 'value2', 'parent_key': { 'nested_key': 'nested_value', 'nested_key2': 'nested_value2', }, } expected = { 'key': 'value', 'parent_key': { 'nested_key': 'nested_value', }, } # Expected being a subset should result in no differences assert _assert_dict_subset(actual, expected) == {}
def test_assert_dict_subset_not_equal(): """Test that assert_dict_subset correctly identifies when expected is not a subset of actual.""" actual = { 'key': 'value', 'key2': 'value2', 'parent_key': { 'nested_key': 'nested_value', 'nested_key2': 'nested_value2', 'different_nested_key': 'not_different_value', }, 'different_key': 'not_different_value', } expected = { 'key': 'value', 'parent_key': { 'nested_key': 'nested_value', 'missing_nested_key': 'missing_value', 'different_nested_key': 'different_value', }, 'missing_key': 'missing_value', 'different_key': 'different_value', } # Make sure we identify missing and different values assert _assert_dict_subset(actual, expected) == { 'parent_key.missing_nested_key': { 'expected': 'missing_value', 'key_present': False, }, 'parent_key.different_nested_key': { 'expected': 'different_value', 'actual': 'not_different_value', }, 'missing_key': { 'expected': 'missing_value', 'key_present': False, }, 'different_key': { 'expected': 'different_value', 'actual': 'not_different_value', } }
def test_assert_dict_subset_not_equal(): """Test that assert_dict_subset correctly identifies when expected is not a subset of actual.""" actual = { "key": "value", "key2": "value2", "parent_key": { "nested_key": "nested_value", "nested_key2": "nested_value2", "different_nested_key": "not_different_value", }, "different_key": "not_different_value", } expected = { "key": "value", "parent_key": { "nested_key": "nested_value", "missing_nested_key": "missing_value", "different_nested_key": "different_value", }, "missing_key": "missing_value", "different_key": "different_value", } # Make sure we identify missing and different values assert _assert_dict_subset(actual, expected) == { "parent_key.missing_nested_key": { "expected": "missing_value", "key_present": False, }, "parent_key.different_nested_key": { "expected": "different_value", "actual": "not_different_value", }, "missing_key": { "expected": "missing_value", "key_present": False }, "different_key": { "expected": "different_value", "actual": "not_different_value", }, }
def test_assert_dict_subset_equal(): """Test that assert_dict_subset correctly identifies equal dicts.""" actual = { "key": "value", "parent_key": { "nested_key": "nested_value" }, "list": ["foo"], "empty_list": [], "none": None, } expected = { "key": "value", "parent_key": { "nested_key": "nested_value" }, "list": ["foo"], "empty_list": [], "none": None, } # Equal dicts should result in no differences assert _assert_dict_subset(actual, expected) == {}
def test_assert_dict_subset_equal(): """Test that assert_dict_subset correctly identifies equal dicts.""" actual = { 'key': 'value', 'parent_key': { 'nested_key': 'nested_value', }, 'list': ['foo'], 'empty_list': [], 'none': None, } expected = { 'key': 'value', 'parent_key': { 'nested_key': 'nested_value', }, 'list': ['foo'], 'empty_list': [], 'none': None, } # Equal dicts should result in no differences assert _assert_dict_subset(actual, expected) == {}