def testMergeNameToProperty(self): dictionary = _build_model_one('@@PROP:server1a@@') new_dictionary = _build_model_two('m1') variables = _build_variable_map() cla_helper._merge_dictionaries(dictionary, new_dictionary, variables) # print("Merged model: " + str(dictionary)) self._check_merged_server(dictionary, '@@PROP:server1a@@')
def testMergeNameToDeletedName(self): dictionary = _build_delete_model('m1') new_dictionary = _build_model_two('m1') variables = {} cla_helper._merge_dictionaries(dictionary, new_dictionary, variables) # print("Merged model: " + str(dictionary)) server = self._check_single_server(dictionary, 'm1') self.assertEquals(2, len(server), "server should have two attributes")
def testMergeDeletedNameToName(self): dictionary = _build_model_one('m1') new_dictionary = _build_delete_model('m1') variables = {} cla_helper._merge_dictionaries(dictionary, new_dictionary, variables) # print("Merged model: " + str(dictionary)) servers = dictionary['Servers'] self.assertEquals(0, len(servers), "there should be no servers after delete")
def testMergeMatchingProperties(self): dictionary = _build_model_one('@@PROP:server1@@') new_dictionary = _build_model_two('@@PROP:server1@@') variables = {} # no variables are needed to resolve this cla_helper._merge_dictionaries(dictionary, new_dictionary, variables) # print("Merged model: " + str(dictionary)) servers = dictionary['Servers'] self.assertEquals(1, len(servers), "there should be one server") self._check_merged_server(dictionary, '@@PROP:server1@@')
def testMergeModels(self): dictionary = { "Servers": { "m1": { "ListenPort": 9000, "ListenDelaySecs": 5 }, "m2": { "ListenPort": 9002 } } } new_dictionary = { "Servers": { "m1": { "ListenPort": 9001, "MaxOpenSockCount": 7, }, "m3": { "ListenPort": 9003 } } } variables = {} cla_helper._merge_dictionaries(dictionary, new_dictionary, variables) # print("Merged model: " + str(dictionary)) servers = dictionary['Servers'] m1 = servers['m1'] self.assertEquals(9001, m1['ListenPort'], "m1 should have listen port 9001") self.assertEquals(5, m1['ListenDelaySecs'], "m1 should have listen delay secs 5") self.assertEquals(7, m1['MaxOpenSockCount'], "m1 should have max open sock count 7") self.assertEquals(9002, servers['m2']['ListenPort'], "m2 should be in model, listen port 9002") self.assertEquals(9003, servers['m3']['ListenPort'], "m3 should be in model, listen port 9003")