def test_mergeData(self): """ Verify we don't lose keys which are present in the old but not replaced in the new. """ old = ConfigDict({ "Scheduling": ConfigDict({ "iMIP": ConfigDict({ "Enabled": True, "Receiving": ConfigDict({ "Username": "******", "Server": "example.com", }), "Sending": ConfigDict({ "Username": "******", }), "AddressPatterns": ["mailto:.*"], }), }), }) new = ConfigDict({ "Scheduling": ConfigDict({ "iMIP": ConfigDict({ "Enabled": False, "Receiving": ConfigDict({ "Username": "******", }), }), }), }) mergeData(old, new) self.assertEquals(old.Scheduling.iMIP.Receiving.Server, "example.com") self.assertEquals(old.Scheduling.iMIP.Sending.Username, "plugh")
def test_mergeData(self): """ Verify we don't lose keys which are present in the old but not replaced in the new. """ old = ConfigDict({ "Scheduling" : ConfigDict({ "iMIP" : ConfigDict({ "Enabled" : True, "Receiving" : ConfigDict({ "Username" : "xyzzy", "Server" : "example.com", }), "Sending" : ConfigDict({ "Username" : "plugh", }), "AddressPatterns" : ["mailto:.*"], }), }), }) new = ConfigDict({ "Scheduling" : ConfigDict({ "iMIP" : ConfigDict({ "Enabled" : False, "Receiving" : ConfigDict({ "Username" : "changed", }), }), }), }) mergeData(old, new) self.assertEquals(old.Scheduling.iMIP.Receiving.Server, "example.com") self.assertEquals(old.Scheduling.iMIP.Sending.Username, "plugh")
def set(self, data): """ Merges data into a ConfigDict of changes intended to be saved to disk when save( ) is called. @param data: a dict containing new values @type data: C{dict} """ if not isinstance(data, ConfigDict): data = ConfigDict(mapping=data) mergeData(self.currentConfigSubset, data) self.dirty = True