Exemplo n.º 1
0
 def test_yamify(self):
     xpdobj = XPD()
     xpdobj.name = ' test'
     xpdobj.type = 'b t'
     yaml_dir = glbl.yaml_dir
     objlist = []
     lname = os.path.join(yaml_dir, '_acqobj_list.yml')
     #initialize the objlist yaml file if it doesn't exist
     if not os.path.isfile(lname):
         fo = open(lname, 'w')
         yaml.dump(objlist, fo)
     testfname = os.path.join(yaml_dir, 'bt_test.yml')
     probe = xpdobj._yamify()
     newobjlist = _get_yaml_list()
     self.assertEqual(newobjlist, self.stbt_list + ['bt_test.yml'])
     xpdobj2 = XPD()
     xpdobj2.name = ' test2'
     xpdobj2.type = 'b t'
     testfname2 = os.path.join(yaml_dir, 'bt_test2.yml')
     probe2 = xpdobj2._yamify()
     newobjlist2 = _get_yaml_list()
     self.assertEqual(newobjlist2,
                      self.stbt_list + ['bt_test.yml', 'bt_test2.yml'])
     self.assertEqual(probe, testfname)
     self.assertTrue(os.path.isfile(probe))
     # try adding another item that is already there
     probe3 = xpdobj2._yamify()
     newobjlist3 = _get_yaml_list()
     self.assertEqual(newobjlist3,
                      self.stbt_list + ['bt_test.yml', 'bt_test2.yml'])