Update tests to include drive_one and getgumtreexmlvalues
This commit is contained in:
@@ -252,6 +252,9 @@ class Baker(Able):
|
||||
self.assertTrue('control' in id_list)
|
||||
|
||||
def test_004_002_gumtreexml(self):
|
||||
global config, hipadaba
|
||||
if not ('pfeiffer_hg' in config.sections() and config.get("pfeiffer_hg", "enabled") == "True"):
|
||||
raise unittest.SkipTest("Pfeiffer PS9 is not configured")
|
||||
child = gumtreexml
|
||||
for node in "/sample/ps9/".strip('/').split('/'):
|
||||
children = [ch for ch in child.findall('component') if ch.attrib['id'].lower() == node.lower()]
|
||||
@@ -261,7 +264,38 @@ class Baker(Able):
|
||||
self.assertTrue(len([ch.attrib['id'] for ch in child.findall('component')]) > 0)
|
||||
self.assertTrue(len([(ch.attrib['id'], [v.text for v in ch.findall('value')]) for ch in child.findall('property')]) > 0)
|
||||
|
||||
def Test_005_000_drive(self):
|
||||
def test_004_003_gumtreexmlvalues(self):
|
||||
#raise unittest.SkipTest("Not doing this test now")
|
||||
d = self.send_command("getgumtreexmlvalues /")
|
||||
def cb3(result, *args, **kw):
|
||||
global gumtreexml
|
||||
#print "XML:", len(result)
|
||||
if "</hipadaba:SICS>" != result[-1]:
|
||||
raise Exception("XML is not complete, ends:" + repr(result[-1]))
|
||||
txt = []
|
||||
for line in result:
|
||||
txt.append(''.join(c for c in line if ord(c) >= 32))
|
||||
gumtreexml = HipadabaTree('\n'.join(txt)).root
|
||||
d.addCallback(cb3)
|
||||
return d
|
||||
|
||||
def test_004_004_gumtreexmlvalues(self):
|
||||
self.assertTrue(gumtreexml.attrib == {})
|
||||
id_list = []
|
||||
for child in gumtreexml.findall('component'):
|
||||
id_list.append(child.attrib['id'])
|
||||
#print child, child.tag, child.attrib
|
||||
#for grandchild in child.findall('component'):
|
||||
# print " ", grandchild.attrib
|
||||
self.assertTrue('commands' in id_list)
|
||||
self.assertTrue('instrument' in id_list)
|
||||
self.assertTrue('sample' in id_list)
|
||||
self.assertTrue('monitor' in id_list)
|
||||
self.assertTrue('user' in id_list)
|
||||
self.assertTrue('experiment' in id_list)
|
||||
self.assertTrue('control' in id_list)
|
||||
|
||||
def Test_005_000_drive_skip(self):
|
||||
"""Skipping example
|
||||
|
||||
Skips on the basis that the equipment to be tested is not configured
|
||||
@@ -277,7 +311,7 @@ class Baker(Able):
|
||||
d.addCallback(cb3)
|
||||
return d
|
||||
|
||||
def test_006_000_drive(self):
|
||||
def test_006_000_drive_zero(self):
|
||||
"""Drive to where the motors already are
|
||||
|
||||
Should finish quickly
|
||||
@@ -310,7 +344,52 @@ class Baker(Able):
|
||||
d = self.send_command("m1")
|
||||
d.addCallback(cb1)
|
||||
return self.deferred
|
||||
test_006_000_drive.timeout = 10
|
||||
test_006_000_drive_zero.timeout = 5
|
||||
|
||||
def test_006_001_drive_one(self):
|
||||
"""Drive to where the motors already are
|
||||
|
||||
Should finish quickly
|
||||
"""
|
||||
self.deferred = defer.Deferred()
|
||||
def cb3(result, *args, **kw):
|
||||
#print "Drive:", result
|
||||
if "Driving finished successfully" != result[-1]:
|
||||
raise Exception("Drive is not complete, ends:" + repr(result[-1]))
|
||||
for item in result:
|
||||
if item.startswith("New m1 position:"):
|
||||
self.assertTrue(round(float(item.split(":")[1]) - self.m1, 2) == 0,
|
||||
"Motor m1 position %f not equal target %f" % (float(item.split(":")[1]), self.m1))
|
||||
if item.startswith("New m2 position:"):
|
||||
self.assertTrue(round(float(item.split(":")[1]) - self.m2, 2) == 0,
|
||||
"Motor m2 position %f not equal target %f" % (float(item.split(":")[1]), self.m2))
|
||||
self.deferred.callback(True)
|
||||
def cb2(result, *args, **kw):
|
||||
#print "m2:", result
|
||||
if not result[0].startswith("m2 = "):
|
||||
raise Exception("Unexpected m2 response: " + repr(result))
|
||||
self.m2 = float(result[0].split("=")[1])
|
||||
if self.m1 > 20:
|
||||
self.m1 = round(self.m1 - 1, 0)
|
||||
else:
|
||||
self.m1 = round(self.m1 + 1, 0)
|
||||
if self.m2 > 20:
|
||||
self.m2 = round(self.m2 - 1, 0)
|
||||
else:
|
||||
self.m2 = round(self.m2 + 1, 0)
|
||||
d = self.send_command("drive m1 %.3f m2 %.3f" % (self.m1, self.m2))
|
||||
d.addCallback(cb3)
|
||||
def cb1(result, *args, **kw):
|
||||
#print "m1:", result
|
||||
if not result[0].startswith("m1 = "):
|
||||
raise Exception("Unexpected m1 response: " + repr(result))
|
||||
self.m1 = float(result[0].split("=")[1])
|
||||
d = self.send_command("m2")
|
||||
d.addCallback(cb2)
|
||||
d = self.send_command("m1")
|
||||
d.addCallback(cb1)
|
||||
return self.deferred
|
||||
test_006_001_drive_one.timeout = 20
|
||||
|
||||
def Test_007_000_mercury(self):
|
||||
raise unittest.SkipTest("Not doing this test now (borken)")
|
||||
@@ -320,13 +399,12 @@ class Baker(Able):
|
||||
if debug:
|
||||
print "\nMercury:", result.short_tree()
|
||||
self.deferred.callback(result)
|
||||
if "mercury_scpi" in config.sections() and config.get("mercury_scpi", "enabled"):
|
||||
self.deferred = defer.Deferred()
|
||||
d = self.load_hipadaba("/sample/%s" % config.get("mercury_scpi", "name"))
|
||||
d.addCallback(cb0)
|
||||
return self.deferred
|
||||
else:
|
||||
if not ("mercury_scpi" in config.sections() and config.get("mercury_scpi", "enabled") == "True"):
|
||||
raise unittest.SkipTest("mercury_scpi is not configured")
|
||||
self.deferred = defer.Deferred()
|
||||
d = self.load_hipadaba("/sample/%s" % config.get("mercury_scpi", "name"))
|
||||
d.addCallback(cb0)
|
||||
return self.deferred
|
||||
Test_007_000_mercury.timeout = 2
|
||||
|
||||
def test_008_000_mercury_hipadaba(self):
|
||||
@@ -336,50 +414,52 @@ class Baker(Able):
|
||||
debug = False
|
||||
if not 'hipadaba' in globals() or hipadaba is None:
|
||||
raise unittest.SkipTest("hipadaba is missing")
|
||||
else:
|
||||
if False:
|
||||
hipadaba.print_tree()
|
||||
root_children = hipadaba.getChildren('/')
|
||||
if debug:
|
||||
print "Children:", root_children
|
||||
root_children = [i.lower() for i in root_children]
|
||||
self.assertTrue('sample' in root_children)
|
||||
sample_children = hipadaba.getChildren('/sample')
|
||||
if debug:
|
||||
print "Children:", sample_children
|
||||
sample_children = [i.lower() for i in sample_children]
|
||||
self.assertTrue('tc9' in sample_children)
|
||||
level_children = hipadaba.getChildren('/sample/tc9/level/')
|
||||
if debug:
|
||||
print "Children:", level_children
|
||||
level_children = [i.lower() for i in level_children]
|
||||
self.assertTrue('helium' in level_children)
|
||||
self.assertTrue('nitrogen' in level_children)
|
||||
he_props = hipadaba.getProperties('/sample/tc9/level/helium')
|
||||
if debug:
|
||||
print "Properties:", he_props
|
||||
he_props = [i.lower() for i in he_props]
|
||||
self.assertTrue('data' in he_props)
|
||||
self.assertTrue('control' in he_props)
|
||||
self.assertTrue('nxsave' in he_props)
|
||||
self.assertTrue('nxalias' in he_props)
|
||||
nxalias = hipadaba.getProperty('/sample/tc9/level/helium', 'NXalias')
|
||||
if debug:
|
||||
print "Prop:", nxalias
|
||||
self.assertTrue(nxalias.lower() == 'tc9_level_helium'.lower())
|
||||
y = hipadaba.getValue('/sample/tc9/Level/helium')
|
||||
if debug:
|
||||
print "Value:", y
|
||||
y = hipadaba.getNode('/sample/tc9/level/helium')
|
||||
if debug:
|
||||
print "Found:", hipadaba.short_tree(y)
|
||||
if debug:
|
||||
hipadaba.print_tree(y)
|
||||
text = hipadaba.list_tree(y, props=True, indent=6)
|
||||
if debug:
|
||||
print "Tree (/sample/tc9/level/helium):"
|
||||
for line in text:
|
||||
print line
|
||||
if not ('mercury_scpi' in config.sections() and config.get("mercury_scpi", "enabled") == "True"):
|
||||
raise unittest.SkipTest("Mercury TC9 is not configured")
|
||||
|
||||
if False:
|
||||
hipadaba.print_tree()
|
||||
root_children = hipadaba.getChildren('/')
|
||||
if debug:
|
||||
print "Children:", root_children
|
||||
root_children = [i.lower() for i in root_children]
|
||||
self.assertTrue('sample' in root_children)
|
||||
sample_children = hipadaba.getChildren('/sample')
|
||||
if debug:
|
||||
print "Children:", sample_children
|
||||
sample_children = [i.lower() for i in sample_children]
|
||||
self.assertTrue('tc9' in sample_children)
|
||||
level_children = hipadaba.getChildren('/sample/tc9/level/')
|
||||
if debug:
|
||||
print "Children:", level_children
|
||||
level_children = [i.lower() for i in level_children]
|
||||
self.assertTrue('helium' in level_children)
|
||||
self.assertTrue('nitrogen' in level_children)
|
||||
he_props = hipadaba.getProperties('/sample/tc9/level/helium')
|
||||
if debug:
|
||||
print "Properties:", he_props
|
||||
he_props = [i.lower() for i in he_props]
|
||||
self.assertTrue('data' in he_props)
|
||||
self.assertTrue('control' in he_props)
|
||||
self.assertTrue('nxsave' in he_props)
|
||||
self.assertTrue('nxalias' in he_props)
|
||||
nxalias = hipadaba.getProperty('/sample/tc9/level/helium', 'NXalias')
|
||||
if debug:
|
||||
print "Prop:", nxalias
|
||||
self.assertTrue(nxalias.lower() == 'tc9_level_helium'.lower())
|
||||
y = hipadaba.getValue('/sample/tc9/Level/helium')
|
||||
if debug:
|
||||
print "Value:", y
|
||||
y = hipadaba.getNode('/sample/tc9/level/helium')
|
||||
if debug:
|
||||
print "Found:", hipadaba.short_tree(y)
|
||||
if debug:
|
||||
hipadaba.print_tree(y)
|
||||
text = hipadaba.list_tree(y, props=True, indent=6)
|
||||
if debug:
|
||||
print "Tree (/sample/tc9/level/helium):"
|
||||
for line in text:
|
||||
print line
|
||||
|
||||
class Zulu(Able):
|
||||
def test_performance(self):
|
||||
|
||||
Reference in New Issue
Block a user