From 393f0503382e4a22a7c58de87e3da103b4ae06cf Mon Sep 17 00:00:00 2001 From: Douglas Clowes Date: Fri, 30 May 2014 17:45:58 +1000 Subject: [PATCH] Update sics_test.py to add position_names and embedded python tests --- .../TEST_SICS/unit_tests/sics_test.py | 79 +++++++++++++++++++ 1 file changed, 79 insertions(+) diff --git a/site_ansto/instrument/TEST_SICS/unit_tests/sics_test.py b/site_ansto/instrument/TEST_SICS/unit_tests/sics_test.py index f17e3756..dbe8de31 100644 --- a/site_ansto/instrument/TEST_SICS/unit_tests/sics_test.py +++ b/site_ansto/instrument/TEST_SICS/unit_tests/sics_test.py @@ -481,7 +481,86 @@ class Baker(Able): for line in text: print line +class Charlie(Able): + timeout = 5 + def test_000_000_posit(self): + debug = True + def cb(result, *args, **kw): + if debug: + print "\nposit:", result, args, kw + phase = args[0] + target = 1 + if phase == target: + d = self.send_command("m1 positions 10 20 30") + d.addCallback(cb, phase + 1) + return + target += 1 + if phase == target: + d = self.send_command("m1 position_names One Two Three") + d.addCallback(cb, phase + 1) + return + target += 1 + if phase == target: + d = self.send_command("m1 position_names") + d.addCallback(cb, phase + 1) + return + target += 1 + if phase == target: + d = self.send_command("m1 softzero") + d.addCallback(cb, phase + 1) + return + target += 1 + if phase == target: + d = self.send_command("m1 posit2hard three") + d.addCallback(cb, phase + 1) + return + target += 1 + if phase == target: + d = self.send_command("m1 posit2soft three") + d.addCallback(cb, phase + 1) + return + + self.deferred.callback(True) + self.deferred = defer.Deferred(); + d = self.send_command("m1 positions erase") + d.addCallback(cb, 1) + return self.deferred + + def test_001_000_python(self): + debug = True + def cb(result, *args, **kw): + if debug: + print "\npython:", result, args, kw + phase = args[0] + target = 0 + target += 1 + if phase == target: + if result[0].startswith("python=obj, type=python,"): + d = self.send_command("python sics.puts(\"Hello Sailor\")") + d.addCallback(cb, phase + 1) + else: + raise unittest.SkipTest("Python is not configured") + return + + target += 1 + if phase == target: + if result[0].startswith("Hello Sailor"): + d = self.send_command("python sics.puts(sics.sics(\"clientput Hello World\"))") + d.addCallback(cb, phase + 1) + return + + target += 1 + if phase == target: + self.assertTrue(result[0].startswith("Hello World")) + + self.deferred.callback(True) + self.deferred = defer.Deferred(); + d = self.send_command("sicslist python") + d.addCallback(cb, 1) + return self.deferred + class Zulu(Able): + timeout = 5 def test_performance(self): d = self.send_command("performance") def cb3(result, *args, **kw):