Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Travis config #311

Merged
merged 2 commits into from
Jan 8, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# This config file for Travis CI utilizes ros-industrial/industrial_ci package.
# For more info for the package, see https://github.com/ros-industrial/industrial_ci/blob/master/README.rst

dist: xenial
dist: trusty
sudo: required
services:
- docker
language: generic
Expand Down
18 changes: 13 additions & 5 deletions rosbridge_library/test/capabilities/test_call_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

from json import loads, dumps
from std_msgs.msg import String
from std_srvs.srv import SetBool

from rosbridge_library.capabilities.call_service import CallService
from rosbridge_library.protocol import Protocol
Expand All @@ -34,15 +35,14 @@ def test_invalid_arguments(self):
self.assertRaises(InvalidArgumentException, s.call_service, msg)

def test_call_service_works(self):
# First, call the service the 'proper' way
p = rospy.ServiceProxy("/rosout/get_loggers", GetLoggers)
# Prepare to call the service the 'proper' way
p = rospy.ServiceProxy(rospy.get_name() + "/get_loggers", GetLoggers)
p.wait_for_service()
time.sleep(1.0)
ret = p()

proto = Protocol("test_call_service_works")
s = CallService(proto)
msg = loads(dumps({"op": "call_service", "service": "/rosout/get_loggers"}))
msg = loads(dumps({"op": "call_service", "service": rospy.get_name() + "/get_loggers"}))

received = {"msg": None, "arrived": False}

Expand All @@ -61,15 +61,23 @@ def cb(msg, cid=None):
break
time.sleep(0.1)

# The rosbridge service call actually causes another logger to appear,
# so do the "regular" service call after that.
ret = p()

self.assertTrue(received["msg"]["result"])
for x, y in zip(ret.loggers, received["msg"]["values"]["loggers"]):
self.assertEqual(x.name, y["name"])
self.assertEqual(x.level, y["level"])

def test_call_service_fail(self):
# Dummy service that instantly fails
service_server = rospy.Service("set_bool_fail", SetBool,
lambda req: None)

proto = Protocol("test_call_service_fail")
s = CallService(proto)
send_msg = loads(dumps({"op": "call_service", "service": "/rosout/set_logger_level", "args": '["ros", "invalid"]'}))
send_msg = loads(dumps({"op": "call_service", "service": rospy.get_name() + "/set_bool_fail", "args": '[ true ]'}))

received = {"msg": None, "arrived": False}
def cb(msg, cid=None):
Expand Down
10 changes: 6 additions & 4 deletions rosbridge_library/test/internal/test_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,19 +133,21 @@ def test_populate_request_args(self):
def test_service_call(self):
""" Test a simple getloggers service call """
# First, call the service the 'proper' way
p = rospy.ServiceProxy("/rosout/get_loggers", GetLoggers)
p = rospy.ServiceProxy(rospy.get_name() + "/get_loggers", GetLoggers)
p.wait_for_service(0.5)
ret = p()

# Now, call using the services
json_ret = services.call_service("/rosout/get_loggers")
json_ret = services.call_service(rospy.get_name() + "/get_loggers")
for x, y in zip(ret.loggers, json_ret["loggers"]):
self.assertEqual(x.name, y["name"])
self.assertEqual(x.level, y["level"])

def test_service_caller(self):
""" Same as test_service_call but via the thread caller """
# First, call the service the 'proper' way
p = rospy.ServiceProxy("/rosout/get_loggers", GetLoggers)
p = rospy.ServiceProxy(rospy.get_name() + "/get_loggers", GetLoggers)
p.wait_for_service(0.5)
ret = p()

rcvd = {"json": None}
Expand All @@ -157,7 +159,7 @@ def error():
raise Exception()

# Now, call using the services
services.ServiceCaller("/rosout/get_loggers", None, success, error).start()
services.ServiceCaller(rospy.get_name() + "/get_loggers", None, success, error).start()

time.sleep(0.5)

Expand Down