From 0f37f19b40abfc744da083cb655ce51b9e52fc45 Mon Sep 17 00:00:00 2001 From: Oleg Kalachev Date: Fri, 18 Feb 2022 22:52:59 +0300 Subject: [PATCH] Basic tests for Blocks --- clover/test/basic.py | 26 ++++++++++++++++++++++++++ clover/test/basic.test | 2 ++ 2 files changed, 28 insertions(+) diff --git a/clover/test/basic.py b/clover/test/basic.py index 283180ed..5d9d6c29 100755 --- a/clover/test/basic.py +++ b/clover/test/basic.py @@ -33,3 +33,29 @@ def test_web_video_server(node): # Python 3 import urllib.request as urllib urllib.urlopen("http://localhost:8080").read() + +def test_blocks(node): + rospy.wait_for_service('clover_blocks/run', timeout=5) + rospy.wait_for_service('clover_blocks/stop', timeout=5) + rospy.wait_for_service('clover_blocks/load', timeout=5) + rospy.wait_for_service('clover_blocks/store', timeout=5) + + from std_msgs.msg import String + from clover_blocks.srv import Run + + def wait_print(): + try: + wait_print.result = rospy.wait_for_message('clover_blocks/print', String, timeout=5).data + except Exception as e: + wait_print.result = str(e) + + import threading + t = threading.Thread(target=wait_print) + t.start() + rospy.sleep(0.1) + + run = rospy.ServiceProxy('clover_blocks/run', Run) + assert run(code='print("test")').success == True + + t.join() + assert wait_print.result == 'test' diff --git a/clover/test/basic.test b/clover/test/basic.test index d27dcc8b..3aac7f10 100755 --- a/clover/test/basic.test +++ b/clover/test/basic.test @@ -35,6 +35,8 @@ startup: { r: 255, g: 255, b: 255 } + +