Example #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'])
Example #2
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'])
Example #3
0
 def test_make_sample(self):
     name = 'my sample '
     self.ex = Experiment('myexp',self.bt)
     self.sa = Sample(name,self.ex)
     self.assertIsInstance(self.sa,Sample)
     self.assertEqual(self.sa.md['bt_experimenters'],[('van der Banerjee','S0ham',1),('Terban','Max',2)])
     self.assertEqual(self.sa.md['bt_piLast'],'Billinge')
     self.assertEqual(self.sa.md['bt_safN'],234)
     self.assertEqual(self.sa.md['bt_wavelength'],None)
     self.assertEqual(self.sa.md['ex_name'],'myexp')
     self.assertEqual(self.sa.md['sa_name'],'my sample')
     uid1 = self.sa.md['sa_uid']
     newobjlist = _get_yaml_list()
     self.assertEqual(newobjlist,self.stbt_list+['ex_myexp.yml','sa_mysample.yml'])
     self.sa2 = Sample(' your sample',self.ex)
     self.assertEqual(self.sa2.md['sa_name'],'your sample')
     uid2 = self.sa2.md['sa_uid']
     self.assertNotEqual(uid1,uid2)
     newobjlist = _get_yaml_list()
     self.assertEqual(newobjlist,self.stbt_list+['ex_myexp.yml','sa_mysample.yml','sa_yoursample.yml'])
     self.sa3 = Sample(' your sample',self.ex)
     self.assertEqual(self.sa3.md['sa_name'],'your sample')
     uid3 = self.sa3.md['sa_uid']
     self.assertEqual(uid2,uid3)
     newobjlist = _get_yaml_list()
     self.assertEqual(newobjlist,self.stbt_list+['ex_myexp.yml','sa_mysample.yml','sa_yoursample.yml'])
Example #4
0
 def test_make_sample(self):
     name = 'my sample '
     self.ex = Experiment('myexp', self.bt)
     self.sa = Sample(name, self.ex)
     self.assertIsInstance(self.sa, Sample)
     self.assertEqual(self.sa.md['bt_experimenters'],
                      [('van der Banerjee', 'S0ham', 1),
                       ('Terban', 'Max', 2)])
     self.assertEqual(self.sa.md['bt_piLast'], 'Billinge')
     self.assertEqual(self.sa.md['bt_safN'], 234)
     self.assertEqual(self.sa.md['bt_wavelength'], None)
     self.assertEqual(self.sa.md['ex_name'], 'myexp')
     self.assertEqual(self.sa.md['sa_name'], 'my sample')
     uid1 = self.sa.md['sa_uid']
     newobjlist = _get_yaml_list()
     self.assertEqual(newobjlist,
                      self.stbt_list + ['ex_myexp.yml', 'sa_mysample.yml'])
     self.sa2 = Sample(' your sample', self.ex)
     self.assertEqual(self.sa2.md['sa_name'], 'your sample')
     uid2 = self.sa2.md['sa_uid']
     self.assertNotEqual(uid1, uid2)
     newobjlist = _get_yaml_list()
     self.assertEqual(
         newobjlist, self.stbt_list +
         ['ex_myexp.yml', 'sa_mysample.yml', 'sa_yoursample.yml'])
     self.sa3 = Sample(' your sample', self.ex)
     self.assertEqual(self.sa3.md['sa_name'], 'your sample')
     uid3 = self.sa3.md['sa_uid']
     self.assertEqual(uid2, uid3)
     newobjlist = _get_yaml_list()
     self.assertEqual(
         newobjlist, self.stbt_list +
         ['ex_myexp.yml', 'sa_mysample.yml', 'sa_yoursample.yml'])
Example #5
0
 def test_start_beamtime(self):
     os.chdir(self.base_dir)
     # clean environment checked above, so only check a case that works
     os.mkdir(self.home_dir)
     os.mkdir(self.config_dir)
     loadinfo = {
         'saf number': self.saf_num,
         'PI last name': self.PI_name,
         'experimenter list': self.experimenters
     }
     with open(self.saffile, 'w') as fo:
         yaml.dump(loadinfo, fo)
     self.assertTrue(os.path.isfile(self.saffile))
     bt = _start_beamtime(self.saf_num, home_dir=self.home_dir)
     self.assertEqual(os.getcwd(),
                      self.home_dir)  # we should be in home, are we?
     self.assertIsInstance(
         bt, bts.Beamtime)  # there should be a bt object, is there?
     self.assertEqual(bt.md['bt_experimenters'],
                      [('van der Banerjee', 'S0ham', 1),
                       ('Terban', 'Max', 2)])
     self.assertEqual(bt.md['bt_piLast'], 'Billinge')
     self.assertEqual(bt.md['bt_safN'], 123)
     self.assertEqual(bt.md['bt_wavelength'], None)
     os.chdir(self.base_dir)
     newobjlist = _get_yaml_list()
     strtScnLst = [
         'bt_bt.yml', 'ex_l-user.yml', 'sa_l-user.yml', 'sp_ct_0.1.yml',
         'sp_ct_0.5.yml', 'sp_ct_1.yml', 'sp_ct_5.yml', 'sp_ct_10.yml',
         'sp_ct_30.yml'
     ]
     self.assertEqual(newobjlist, strtScnLst)
Example #6
0
 def test_hide(self):
     name = 'my sample '
     self.ex = Experiment('myexp',self.bt)
     self.sa = Sample(name,self.ex)
     newobjlist = _get_yaml_list()
     self.assertEqual(newobjlist,self.stbt_list+['ex_myexp.yml','sa_mysample.yml'])
     self.hidelist = self.bt.hide(1)
     self.assertEqual(self.hidelist,[1])
     hidden_list = _get_hidden_list() 
     self.assertEqual(self.hidelist,hidden_list)
Example #7
0
 def test_make_scanPlan(self):
     self.sp = ScanPlan('myScan','ct',{'exposure':1.0})
     self.assertIsInstance(self.sp,ScanPlan)
     self.assertEqual(self.sp.md['sp_params'],{'exposure':1.0,'subs':['livetable']})
     uid1 = self.sp.md['sp_uid']
     newobjlist = _get_yaml_list()
     self.assertEqual(newobjlist,self.stbt_list+['sp_myScan.yml'])
     self.sp2 = ScanPlan(' your scan','ct',{'exposure':1.0})
     self.assertEqual(self.sp2.md['sp_name'],'your scan')
     uid2 = self.sp2.md['sp_uid']
     self.assertNotEqual(uid1,uid2)
     newobjlist = _get_yaml_list()
     self.assertEqual(newobjlist,self.stbt_list+['sp_myScan.yml','sp_yourscan.yml'])
     self.sp3 = ScanPlan(' your scan','ct',{'exposure':1.0})
     self.assertEqual(self.sp3.md['sp_name'],'your scan')
     uid3 = self.sp3.md['sp_uid']
     self.assertEqual(uid2,uid3)
     # and one that fails the validator
     self.assertRaises(SystemExit,lambda: ScanPlan(' your scan','ct',{'exposur':1.0}))
Example #8
0
 def test_hide(self):
     name = 'my sample '
     self.ex = Experiment('myexp', self.bt)
     self.sa = Sample(name, self.ex)
     newobjlist = _get_yaml_list()
     self.assertEqual(newobjlist,
                      self.stbt_list + ['ex_myexp.yml', 'sa_mysample.yml'])
     self.hidelist = self.bt.hide(1)
     self.assertEqual(self.hidelist, [1])
     hidden_list = _get_hidden_list()
     self.assertEqual(self.hidelist, hidden_list)
Example #9
0
 def test_make_scanPlan(self):
     self.sp = ScanPlan('ct', {'exposure': 0.7})
     self.assertIsInstance(self.sp, ScanPlan)
     self.assertEqual(self.sp.md['sp_params'], {'exposure': 0.7})
     uid1 = self.sp.md['sp_uid']
     newobjlist = _get_yaml_list()
     self.assertEqual(newobjlist, self.stbt_list + ['sp_ct_0.7.yml'])
     self.sp2 = ScanPlan('ct', {'exposure': 1.5})
     self.assertEqual(self.sp2.md['sp_name'], 'ct_1.5')
     uid2 = self.sp2.md['sp_uid']
     self.assertNotEqual(uid1, uid2)
     newobjlist = _get_yaml_list()
     self.assertEqual(newobjlist,
                      self.stbt_list + ['sp_ct_0.7.yml', 'sp_ct_1.5.yml'])
     self.sp3 = ScanPlan('ct', {'exposure': 1.5})
     self.assertEqual(self.sp3.md['sp_name'], 'ct_1.5')
     uid3 = self.sp3.md['sp_uid']
     self.assertEqual(uid2, uid3)
     # and one that fails the validator
     self.assertRaises(SystemExit, lambda: ScanPlan('ct', {'exposur': 1.0}))
Example #10
0
 def test_start_beamtime(self):
     os.chdir(self.base_dir)
     # clean environment checked above, so only check a case that works
     os.mkdir(self.home_dir)
     os.mkdir(self.config_dir)
     loadinfo = {'saf number':self.saf_num,'PI last name':self.PI_name,'experimenter list':self.experimenters}
     with open(self.saffile, 'w') as fo:
         yaml.dump(loadinfo,fo)
     self.assertTrue(os.path.isfile(self.saffile))
     bt = _start_beamtime(self.saf_num,home_dir=self.home_dir)
     self.assertEqual(os.getcwd(),self.home_dir) # we should be in home, are we?
     self.assertIsInstance(bt,bts.Beamtime) # there should be a bt object, is there?
     self.assertEqual(bt.md['bt_experimenters'],[('van der Banerjee','S0ham',1),('Terban','Max',2)])
     self.assertEqual(bt.md['bt_piLast'],'Billinge')
     self.assertEqual(bt.md['bt_safN'],123)
     self.assertEqual(bt.md['bt_wavelength'],None)
     os.chdir(self.base_dir)
     newobjlist = _get_yaml_list()
     strtScnLst = ['bt_bt.yml','ex_l-user.yml','sa_l-user.yml','sp_ct_0.1.yml','sp_ct_0.5.yml','sp_ct_1.yml','sp_ct_5.yml','sp_ct_10.yml','sp_ct_30.yml']
     self.assertEqual(newobjlist,strtScnLst)