Massage the test suite for non-taipan instruments
This commit is contained in:
@ -26,7 +26,10 @@ class Able(unittest.TestCase):
|
|||||||
def cb_login(client, *args, **kw):
|
def cb_login(client, *args, **kw):
|
||||||
if debug:
|
if debug:
|
||||||
print "cb_login:", client, args, kw
|
print "cb_login:", client, args, kw
|
||||||
if 'test_suite' not in globals():
|
if 'instrument_name' not in globals():
|
||||||
|
d = self.get_instrument_name()
|
||||||
|
d.addCallback(cb_login, "Test_Suite")
|
||||||
|
elif 'test_suite' not in globals():
|
||||||
d = self.load_test_suite()
|
d = self.load_test_suite()
|
||||||
d.addCallback(cb_login, "Test_Suite")
|
d.addCallback(cb_login, "Test_Suite")
|
||||||
elif 'sicsconfig' not in globals():
|
elif 'sicsconfig' not in globals():
|
||||||
@ -55,6 +58,20 @@ class Able(unittest.TestCase):
|
|||||||
#print "Command:", command, d
|
#print "Command:", command, d
|
||||||
return d
|
return d
|
||||||
|
|
||||||
|
def get_instrument_name(self):
|
||||||
|
debug = False
|
||||||
|
def cb1(result, *args, **kw):
|
||||||
|
global instrument_name
|
||||||
|
if debug:
|
||||||
|
print "instrument:", result, args, kw
|
||||||
|
self.assertTrue(result[0].lower().startswith("instrument = "))
|
||||||
|
instrument_name = result[0].split("=")[1].strip().lower()
|
||||||
|
if debug:
|
||||||
|
print "Instrument:", instrument_name
|
||||||
|
d = self.send_command("instrument")
|
||||||
|
d.addCallback(cb1)
|
||||||
|
return d
|
||||||
|
|
||||||
def load_test_suite(self):
|
def load_test_suite(self):
|
||||||
debug = False
|
debug = False
|
||||||
def cb1(result, *args, **kw):
|
def cb1(result, *args, **kw):
|
||||||
@ -232,7 +249,7 @@ class Baker(Able):
|
|||||||
for m in ["m1", "m2", "s1", "s2", "a1", "a2"]:
|
for m in ["m1", "m2", "s1", "s2", "a1", "a2"]:
|
||||||
if m not in motors:
|
if m not in motors:
|
||||||
missing.append(m)
|
missing.append(m)
|
||||||
if len(missing) > 0:
|
if instrument_name == "taipan" and len(missing) > 0:
|
||||||
raise Exception("Missing motors:" + repr(missing))
|
raise Exception("Missing motors:" + repr(missing))
|
||||||
d.addCallback(cb3)
|
d.addCallback(cb3)
|
||||||
return d
|
return d
|
||||||
@ -336,6 +353,9 @@ class Baker(Able):
|
|||||||
|
|
||||||
Should finish quickly
|
Should finish quickly
|
||||||
"""
|
"""
|
||||||
|
if instrument_name != "taipan":
|
||||||
|
raise unittest.SkipTest("Cannot drive motor m1, m2: not taipan")
|
||||||
|
|
||||||
self.deferred = defer.Deferred()
|
self.deferred = defer.Deferred()
|
||||||
def cb3(result, *args, **kw):
|
def cb3(result, *args, **kw):
|
||||||
#print "Drive:", result
|
#print "Drive:", result
|
||||||
@ -371,6 +391,9 @@ class Baker(Able):
|
|||||||
|
|
||||||
Should finish quickly
|
Should finish quickly
|
||||||
"""
|
"""
|
||||||
|
if instrument_name != "taipan":
|
||||||
|
raise unittest.SkipTest("Cannot drive motor m1, m2: not taipan")
|
||||||
|
|
||||||
self.deferred = defer.Deferred()
|
self.deferred = defer.Deferred()
|
||||||
def cb3(result, *args, **kw):
|
def cb3(result, *args, **kw):
|
||||||
#print "Drive:", result
|
#print "Drive:", result
|
||||||
@ -481,10 +504,13 @@ class Baker(Able):
|
|||||||
for line in text:
|
for line in text:
|
||||||
print line
|
print line
|
||||||
|
|
||||||
class Charlie(Able):
|
class Posit(Able):
|
||||||
timeout = 5
|
timeout = 5
|
||||||
def test_000_000_posit(self):
|
def test_000_000_posit(self):
|
||||||
debug = True
|
debug = True
|
||||||
|
if instrument_name != "taipan":
|
||||||
|
raise unittest.SkipTest("Cannot posit motor m1, m2: not taipan")
|
||||||
|
|
||||||
def cb(result, *args, **kw):
|
def cb(result, *args, **kw):
|
||||||
if debug:
|
if debug:
|
||||||
print "\nposit:", result, args, kw
|
print "\nposit:", result, args, kw
|
||||||
@ -526,9 +552,12 @@ class Charlie(Able):
|
|||||||
d.addCallback(cb, 1)
|
d.addCallback(cb, 1)
|
||||||
return self.deferred
|
return self.deferred
|
||||||
|
|
||||||
|
class Python(Able):
|
||||||
|
timeout = 5
|
||||||
def test_001_000_python(self):
|
def test_001_000_python(self):
|
||||||
debug = True
|
debug = False
|
||||||
def cb(result, *args, **kw):
|
def cb(result, *args, **kw):
|
||||||
|
global python_installed
|
||||||
if debug:
|
if debug:
|
||||||
print "\npython:", result, args, kw
|
print "\npython:", result, args, kw
|
||||||
phase = args[0]
|
phase = args[0]
|
||||||
@ -536,12 +565,27 @@ class Charlie(Able):
|
|||||||
target += 1
|
target += 1
|
||||||
if phase == target:
|
if phase == target:
|
||||||
if result[0].startswith("python=obj, type=python,"):
|
if result[0].startswith("python=obj, type=python,"):
|
||||||
d = self.send_command("python sics.puts(\"Hello Sailor\")")
|
python_installed = True
|
||||||
d.addCallback(cb, phase + 1)
|
|
||||||
else:
|
else:
|
||||||
raise unittest.SkipTest("Python is not configured")
|
python_installed = False
|
||||||
return
|
|
||||||
|
|
||||||
|
self.deferred.callback(True)
|
||||||
|
self.deferred = defer.Deferred();
|
||||||
|
d = self.send_command("sicslist python")
|
||||||
|
d.addCallback(cb, 1)
|
||||||
|
return self.deferred
|
||||||
|
|
||||||
|
def test_002_000_python(self):
|
||||||
|
debug = False
|
||||||
|
if debug:
|
||||||
|
print "Python_Installed:", python_installed
|
||||||
|
if not python_installed:
|
||||||
|
raise unittest.SkipTest("Python is not installed")
|
||||||
|
def cb(result, *args, **kw):
|
||||||
|
if debug:
|
||||||
|
print "\npython:", result, args, kw
|
||||||
|
phase = args[0]
|
||||||
|
target = 0
|
||||||
target += 1
|
target += 1
|
||||||
if phase == target:
|
if phase == target:
|
||||||
if result[0].startswith("Hello Sailor"):
|
if result[0].startswith("Hello Sailor"):
|
||||||
@ -555,7 +599,7 @@ class Charlie(Able):
|
|||||||
|
|
||||||
self.deferred.callback(True)
|
self.deferred.callback(True)
|
||||||
self.deferred = defer.Deferred();
|
self.deferred = defer.Deferred();
|
||||||
d = self.send_command("sicslist python")
|
d = self.send_command("python sics.puts(\"Hello Sailor\")")
|
||||||
d.addCallback(cb, 1)
|
d.addCallback(cb, 1)
|
||||||
return self.deferred
|
return self.deferred
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user