Exemplo n.º 1
0
 def testDictionarySet(self):
   self.test_res = HalResource()
   for k in self.res_values.keys():
       msg = 'resource %s has value %s and it was set as %s '%(k, self.test_res[k], self.res_values[k])
       self.assertNotEquals(self.res_values[k], self.test_res[k], msg)
   self.test_res.dictionary = self.res_values
   for k in self.res_values.keys():
       msg = 'resource %s has value %s and it was set as %s '%(k, self.test_res[k], self.res_values[k])
       self.assertEquals(self.res_values[k], self.test_res[k], msg)
Exemplo n.º 2
0
  def __objectify__(self, cfg):
    obj_vars = []
    obj_req_vars = []
    obj_res = []
    obj_req_res = []
    keys_vars = {'Variables': obj_vars, 'RequiredVariables': obj_req_vars}
    keys_res = {'Resources': obj_res, 'RequiredResources': obj_req_res}
    for key in keys_vars.keys():
      if key in cfg:
        for v in cfg[key]:
          keys_vars[key].append(HalVar.from_dict(v))
    for key in keys_res.keys():
      if key in cfg:
        for v in cfg[key]:
          keys_res[key].append(HalResource.from_dict(v))

    cfg['Variables'] = obj_vars
    cfg['RequiredVariables'] = obj_req_vars
    cfg['Resources'] = obj_res
    cfg['RequiredResources'] = obj_req_res
    return cfg
Exemplo n.º 3
0
  def __objectify__(self, cfg):
    obj_vars = []
    obj_req_vars = []
    obj_res = []
    obj_req_res = []
    keys_vars = {'Variables': obj_vars, 'RequiredVariables': obj_req_vars}
    keys_res = {'Resources': obj_res, 'RequiredResources': obj_req_res}
    for key in keys_vars.keys():
      if key in cfg:
        for v in cfg[key]:
          keys_vars[key].append(HalVar.from_dict(v))
    for key in keys_res.keys():
      if key in cfg:
        for v in cfg[key]:
          keys_res[key].append(HalResource.from_dict(v))

    cfg['Variables'] = obj_vars
    cfg['RequiredVariables'] = obj_req_vars
    cfg['Resources'] = obj_res
    cfg['RequiredResources'] = obj_req_res
    return cfg
Exemplo n.º 4
0
 def testToDictionary(self):
   self.test_res = HalResource.from_dict(self.res_values)
   self.assertEquals(len(self.res_values.keys()), len(self.test_res.dictionary.keys()))
Exemplo n.º 5
0
 def testIteration(self):
   self.test_res = HalResource.from_dict(self.res_values)
   d = dict( [(k, v) for k, v in self.test_res.items()])
   self.assertEquals(len(d.keys()), len(self.res_values.keys()), 'Keys dont match')
   for k in d.keys():
     self.assertTrue(self.res_values.has_key(k), 'Unknown key %s'%k)
Exemplo n.º 6
0
 def testIterationOfTheKeys(self):
   self.test_res = HalResource.from_dict(self.res_values)
   for k in self.test_res.keys():
     msg = 'resource %s has value %s and it was set as %s '%(k, self.test_res[k], self.res_values[k])
     self.assertEquals(self.res_values[k], self.test_res[k], msg)