00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 import roslib; roslib.load_manifest('test_rosinstall')
00034
00035 import os
00036 import stat
00037 import struct
00038 import sys
00039 import unittest
00040 import roslib
00041 import rostest
00042
00043 import rosinstall.helpers
00044
00045
00046 class ConditionalAbspath(unittest.TestCase):
00047
00048 def setUp(self):
00049 pass
00050
00051 def tearDown(self):
00052 pass
00053
00054 def test_conditional_abspath(self):
00055 path = "foo"
00056 self.assertEqual(os.path.normpath(os.path.join(os.getcwd(), path)), rosinstall.helpers.conditional_abspath(path))
00057
00058 def test_is_path_stack(self):
00059 self.assertTrue(rosinstall.helpers.is_path_stack(roslib.stacks.get_stack_dir("ros")))
00060 self.assertFalse(rosinstall.helpers.is_path_stack(roslib.packages.get_pkg_dir("roscpp")))
00061
00062 def test_is_path_ros(self):
00063 self.assertTrue(rosinstall.helpers.is_path_stack(roslib.stacks.get_stack_dir("ros")))
00064 self.assertFalse(rosinstall.helpers.is_path_stack(roslib.packages.get_pkg_dir("roscpp")))
00065
00066 def test_get_yaml_from_uri_from_file(self):
00067 file = os.path.join(roslib.packages.get_pkg_dir("test_rosinstall"), "test", "example.yaml")
00068 y = rosinstall.helpers.get_yaml_from_uri(file)
00069
00070 self.assertTrue("text" in y)
00071 self.assertTrue(y["text"] == "foobar")
00072
00073 self.assertTrue("number" in y)
00074 self.assertTrue(y["number"] == 2)
00075
00076 def test_get_yaml_from_uri_from_missing_file(self):
00077 file = "/asdfasdfasdfasfasdf_does_not_exist"
00078 y = rosinstall.helpers.get_yaml_from_uri(file)
00079 self.assertEqual(y, None)
00080
00081
00082
00083
00084
00085
00086
00087 def test_get_yaml_from_uri_from_url(self):
00088 url = "http://www.ros.org/rosinstalls/boxturtle_base.rosinstall"
00089 y = rosinstall.helpers.get_yaml_from_uri(url)
00090
00091 ros_found = False
00092 for e in y:
00093 if "svn" in e:
00094 element = e["svn"]
00095 if "local-name" in element:
00096 if element["local-name"] == "ros":
00097 ros_found = True
00098 self.assertTrue(ros_found)
00099
00100 def test_get_yaml_from_uri_from_invalid_url(self):
00101 url = "http://www.ros.org/invalid"
00102 y = rosinstall.helpers.get_yaml_from_uri(url)
00103 self.assertEqual(y, None)
00104
00105
00106 if __name__ == '__main__':
00107 rostest.unitrun('test_rosinstall', 'test_conditional_abspath', ConditionalAbspath, coverage_packages=['rosinstall'])
00108