def __init__(self, cdict, sdict): self.cdict = cdict self.sdict = sdict self.keys_to_fix = [] self.must_be_deleted = (self.sdict is not None and self.cdict is None) self.must_be_created = (self.cdict is not None and self.sdict is None) if not self.must_be_deleted and not self.must_be_created: self.keys_to_fix = diff_keys(cdict, sdict)
def test_difference(self): self.assertEqual( statedict.diff_keys( {'foo': "bar", 'baz': 1}, {'foo': "bar", 'baz': 2}, ), ['baz'], )
def test_identical(self): self.assertEqual( statedict.diff_keys( {'foo': "bar"}, {'foo': "bar"}, ), [], )
def __init__(self, cdict, sdict): self.cdict = cdict self.sdict = sdict self.keys_to_fix = [] self.must_be_deleted = self.sdict is not None and self.cdict is None self.must_be_created = self.cdict is not None and self.sdict is None if not self.must_be_deleted and not self.must_be_created: self.keys_to_fix = diff_keys(cdict, sdict)
def test_different_keys(self): with self.assertRaises(ValueError): statedict.diff_keys( {'foo': "bar"}, {'bar': "foo"}, )