Split up some of the tests and add a TCL clock test
This commit is contained in:
@ -13,6 +13,7 @@ from twisted.trial import unittest
|
|||||||
from twisted.internet import reactor, protocol, defer
|
from twisted.internet import reactor, protocol, defer
|
||||||
|
|
||||||
import ConfigParser, StringIO
|
import ConfigParser, StringIO
|
||||||
|
from datetime import datetime as dt
|
||||||
|
|
||||||
|
|
||||||
class Able(unittest.TestCase):
|
class Able(unittest.TestCase):
|
||||||
@ -67,24 +68,35 @@ class Able(unittest.TestCase):
|
|||||||
|
|
||||||
class Baker(Able):
|
class Baker(Able):
|
||||||
timeout = 5
|
timeout = 5
|
||||||
def test_000_login(self):
|
def test_000_000_login(self):
|
||||||
debug = False
|
debug = False
|
||||||
self.deferred = defer.Deferred()
|
self.deferred = defer.Deferred()
|
||||||
d = self.sics.login_deferred
|
|
||||||
def cb0(result, *args, **kw):
|
def cb0(result, *args, **kw):
|
||||||
if debug:
|
if debug:
|
||||||
print "Login:", result, args, kw
|
print "Login:", result, args, kw
|
||||||
if self.sics.login != 2:
|
if self.sics.login != 2:
|
||||||
raise Exception("Bad login:" + repr(self.sics.login))
|
raise Exception("Bad login:" + repr(self.sics.login))
|
||||||
d = self.send_command("fileeval TEST_SICS/unit_tests/test_suite.tcl")
|
self.deferred.callback(None)
|
||||||
d.addCallback(cb1)
|
d = self.sics.login_deferred
|
||||||
|
d.addCallback(cb0)
|
||||||
|
return self.deferred
|
||||||
|
|
||||||
|
def test_000_001_fileeval(self):
|
||||||
|
debug = False
|
||||||
|
self.deferred = defer.Deferred()
|
||||||
def cb1(result, *args, **kw):
|
def cb1(result, *args, **kw):
|
||||||
if debug:
|
if debug:
|
||||||
print "fileeval:", result, args, kw
|
print "fileeval:", result, args, kw
|
||||||
if result[0] != "OK":
|
if result[0] != "OK":
|
||||||
raise Exception("fileeval returned " + repr(result))
|
raise Exception("fileeval returned " + repr(result))
|
||||||
d = self.send_command("tcl:test_suite::show_config ::config_dict")
|
self.deferred.callback(None)
|
||||||
d.addCallback(cb2)
|
d = self.send_command("fileeval TEST_SICS/unit_tests/test_suite.tcl")
|
||||||
|
d.addCallback(cb1)
|
||||||
|
return self.deferred
|
||||||
|
|
||||||
|
def test_001_000_config(self):
|
||||||
|
debug = False
|
||||||
|
self.deferred = defer.Deferred()
|
||||||
def cb2(result, *args, **kw):
|
def cb2(result, *args, **kw):
|
||||||
global config
|
global config
|
||||||
if debug:
|
if debug:
|
||||||
@ -108,16 +120,44 @@ class Baker(Able):
|
|||||||
for option in sorted(config.options(section)):
|
for option in sorted(config.options(section)):
|
||||||
print ("%s = %s\n" % (option, config.get(section, option))),
|
print ("%s = %s\n" % (option, config.get(section, option))),
|
||||||
print
|
print
|
||||||
d = self.load_hipadaba()
|
self.deferred.callback(None)
|
||||||
d.addCallback(cb3)
|
d = self.send_command("tcl:test_suite::show_config ::config_dict")
|
||||||
|
d.addCallback(cb2)
|
||||||
|
return self.deferred
|
||||||
|
|
||||||
|
def test_001_001_clock(self):
|
||||||
|
debug = False
|
||||||
|
self.deferred = defer.Deferred()
|
||||||
|
def cb2(result, *args, **kw):
|
||||||
|
if debug:
|
||||||
|
print "Clock:", result
|
||||||
|
formatted = dt.fromtimestamp(1399866027).strftime("%Y-%b-%d %H:%M:%S")
|
||||||
|
self.assertEqual(result[0], formatted)
|
||||||
|
self.deferred.callback(None)
|
||||||
|
def cb3(result, *args, **kw):
|
||||||
|
if debug:
|
||||||
|
print "Clock:", result
|
||||||
|
if not result[0].isdigit():
|
||||||
|
raise Exception("Bad response:" + repr(result))
|
||||||
|
if not 1399865694 <= int(result[0]) < 1499865694:
|
||||||
|
raise Exception("Bad value:" + repr(result))
|
||||||
|
d = self.send_command("tcl:clock format 1399866027 -format \"%Y-%h-%d %T\"")
|
||||||
|
d.addCallback(cb2)
|
||||||
|
d = self.send_command("tcl:clock seconds")
|
||||||
|
d.addCallback(cb3)
|
||||||
|
return self.deferred
|
||||||
|
|
||||||
|
def test_001_002_hipadaba(self):
|
||||||
|
self.deferred = defer.Deferred()
|
||||||
def cb3(result, *args, **kw):
|
def cb3(result, *args, **kw):
|
||||||
global hipadaba
|
global hipadaba
|
||||||
hipadaba = result
|
hipadaba = result
|
||||||
self.deferred.callback(None)
|
self.deferred.callback(None)
|
||||||
d.addCallback(cb0)
|
d = self.load_hipadaba()
|
||||||
|
d.addCallback(cb3)
|
||||||
return self.deferred
|
return self.deferred
|
||||||
|
|
||||||
def test_001_status(self):
|
def test_001_003_status(self):
|
||||||
d = self.send_command("status")
|
d = self.send_command("status")
|
||||||
def cb3(result, *args, **kw):
|
def cb3(result, *args, **kw):
|
||||||
#print "Status:", result
|
#print "Status:", result
|
||||||
@ -126,7 +166,7 @@ class Baker(Able):
|
|||||||
d.addCallback(cb3)
|
d.addCallback(cb3)
|
||||||
return d
|
return d
|
||||||
|
|
||||||
def test_002_dir(self):
|
def Test_002_000_dir(self):
|
||||||
raise unittest.SkipTest("Not doing this test now")
|
raise unittest.SkipTest("Not doing this test now")
|
||||||
self.deferred = defer.Deferred()
|
self.deferred = defer.Deferred()
|
||||||
d = self.send_command("dir types")
|
d = self.send_command("dir types")
|
||||||
@ -160,7 +200,7 @@ class Baker(Able):
|
|||||||
d.addCallback(cb3)
|
d.addCallback(cb3)
|
||||||
return self.deferred
|
return self.deferred
|
||||||
|
|
||||||
def test_003_motor(self):
|
def test_003_000_motors(self):
|
||||||
global motors
|
global motors
|
||||||
motors = []
|
motors = []
|
||||||
d = self.send_command("sicslist type motor")
|
d = self.send_command("sicslist type motor")
|
||||||
@ -221,7 +261,7 @@ class Baker(Able):
|
|||||||
self.assertTrue(len([ch.attrib['id'] for ch in child.findall('component')]) > 0)
|
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)
|
self.assertTrue(len([(ch.attrib['id'], [v.text for v in ch.findall('value')]) for ch in child.findall('property')]) > 0)
|
||||||
|
|
||||||
def test_005_drive(self):
|
def Test_005_000_drive(self):
|
||||||
"""Skipping example
|
"""Skipping example
|
||||||
|
|
||||||
Skips on the basis that the equipment to be tested is not configured
|
Skips on the basis that the equipment to be tested is not configured
|
||||||
@ -237,7 +277,7 @@ class Baker(Able):
|
|||||||
d.addCallback(cb3)
|
d.addCallback(cb3)
|
||||||
return d
|
return d
|
||||||
|
|
||||||
def test_006_drive(self):
|
def test_006_000_drive(self):
|
||||||
"""Drive to where the motors already are
|
"""Drive to where the motors already are
|
||||||
|
|
||||||
Should finish quickly
|
Should finish quickly
|
||||||
@ -270,9 +310,9 @@ class Baker(Able):
|
|||||||
d = self.send_command("m1")
|
d = self.send_command("m1")
|
||||||
d.addCallback(cb1)
|
d.addCallback(cb1)
|
||||||
return self.deferred
|
return self.deferred
|
||||||
test_006_drive.timeout = 10
|
test_006_000_drive.timeout = 10
|
||||||
|
|
||||||
def test_007_mercury(self):
|
def Test_007_000_mercury(self):
|
||||||
raise unittest.SkipTest("Not doing this test now (borken)")
|
raise unittest.SkipTest("Not doing this test now (borken)")
|
||||||
global config, hipadaba
|
global config, hipadaba
|
||||||
debug = False
|
debug = False
|
||||||
@ -287,9 +327,9 @@ class Baker(Able):
|
|||||||
return self.deferred
|
return self.deferred
|
||||||
else:
|
else:
|
||||||
raise unittest.SkipTest("mercury_scpi is not configured")
|
raise unittest.SkipTest("mercury_scpi is not configured")
|
||||||
test_007_mercury.timeout = 2
|
Test_007_000_mercury.timeout = 2
|
||||||
|
|
||||||
def test_008_mercury_hipadaba(self):
|
def test_008_000_mercury_hipadaba(self):
|
||||||
"""Test the hipadaba tree and mechanism
|
"""Test the hipadaba tree and mechanism
|
||||||
"""
|
"""
|
||||||
global hipadaba
|
global hipadaba
|
||||||
|
Reference in New Issue
Block a user