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 import roslib; roslib.load_manifest('test_rosdep')
00033
00034 import os
00035 import struct
00036 import sys
00037 import unittest
00038
00039 import rosunit
00040 import rosdep.core
00041
00042 class RosdepCoreTest(unittest.TestCase):
00043 def setUp(self):
00044 self.rdlp = rosdep.core.RosdepLookupPackage("rosdep_test_os", "rosdep_test_version", "test_rosdep", rosdep.core.YamlCache("rosdep_test_os", "rosdep_test_version", {'apt':'unused'}))
00045
00046 def test_RosdepLookupPackage_parse_yaml_package(self):
00047 rdlp = self.rdlp
00048 yaml_map = rdlp.parse_yaml(os.path.join(roslib.packages.get_pkg_dir("test_rosdep"),"test", "example_rosdep.yaml"))
00049 rdlp._insert_map(yaml_map, "example_yaml_path", False)
00050 output = rdlp.lookup_rosdep("rosdep_test")
00051 self.assertEqual("librosdep_test1.37-dev", output)
00052 output = rdlp.lookup_rosdep("foobar")
00053 self.assertEqual(False, output)
00054
00055
00056 def test_RosdepLookupPackage_parse_yaml_package_override(self):
00057 rdlp = self.rdlp
00058 yaml_map = rdlp.parse_yaml(os.path.join(roslib.packages.get_pkg_dir("test_rosdep"),"test", "example_rosdep.yaml"))
00059 rdlp._insert_map(yaml_map, "example_yaml_path", False)
00060 rdlp._insert_map(yaml_map, "example_yaml_path2", True)
00061 output = rdlp.lookup_rosdep("rosdep_test")
00062 self.assertEqual("librosdep_test1.37-dev", output)
00063 output = rdlp.lookup_rosdep("foobar")
00064 self.assertEqual(False, output)
00065
00066
00067 def test_RosdepLookupPackage_parse_yaml_package_collision_pass(self):
00068 rdlp = self.rdlp
00069 yaml_map = rdlp.parse_yaml(os.path.join(roslib.packages.get_pkg_dir("test_rosdep"),"test", "example_rosdep.yaml"))
00070 rdlp._insert_map(yaml_map, "example_yaml_path", False)
00071 rdlp._insert_map(yaml_map, "example_yaml_path2", False)
00072 output = rdlp.lookup_rosdep("rosdep_test")
00073 self.assertEqual("librosdep_test1.37-dev", output)
00074 output = rdlp.lookup_rosdep("foobar")
00075 self.assertEqual(False, output)
00076
00077
00078 def test_RosdepLookupPackage_parse_yaml_package_collision_fail(self):
00079 rdlp = self.rdlp
00080 yaml_map = rdlp.parse_yaml(os.path.join(roslib.packages.get_pkg_dir("test_rosdep"),"test", "example_rosdep.yaml"))
00081 rdlp._insert_map(yaml_map, "example_yaml_path", False)
00082 yaml_map = rdlp.parse_yaml(os.path.join(roslib.packages.get_pkg_dir("test_rosdep"),"test", "example_rosdep_conflicting.yaml"))
00083 self.assertRaises(rosdep.core.RosdepException, rdlp._insert_map, yaml_map, "example_yaml_path2", False)
00084
00085 def test_RosdepLookupPackage_parse_yaml_package_collision_override(self):
00086 rdlp = self.rdlp
00087 yaml_map = rdlp.parse_yaml(os.path.join(roslib.packages.get_pkg_dir("test_rosdep"),"test", "example_rosdep.yaml"))
00088 rdlp._insert_map(yaml_map, "example_yaml_path", False)
00089 yaml_map = rdlp.parse_yaml(os.path.join(roslib.packages.get_pkg_dir("test_rosdep"),"test", "example_rosdep_conflicting.yaml"))
00090 rdlp._insert_map(yaml_map, "example_yaml_path2", True)
00091 output = rdlp.lookup_rosdep("rosdep_test")
00092 self.assertEqual("not-librosdep_test1.37-dev", output)
00093 output = rdlp.lookup_rosdep("foobar")
00094 self.assertEqual(False, output)
00095
00096 def test_RosdepLookupPackage_get_sources(self):
00097 rdlp = self.rdlp
00098
00099 sources = rdlp.get_sources("rosdep_test")
00100 self.assertEqual([], sources)
00101
00102 yaml_map = rdlp.parse_yaml(os.path.join(roslib.packages.get_pkg_dir("test_rosdep"),"test", "example_rosdep.yaml"))
00103 rdlp._insert_map(yaml_map, "example_yaml_path", False)
00104 rdlp._insert_map(yaml_map, "example_yaml_path2", False)
00105
00106 sources = rdlp.get_sources("rosdep_test")
00107 self.assertEqual(["example_yaml_path", "example_yaml_path2"], sources)
00108
00109 sources = rdlp.get_sources("undefined")
00110 self.assertEqual([], sources)
00111
00112 def test_RosdepLookupPackage_rosdep_map(self):
00113 rdlp = self.rdlp
00114
00115
00116 yaml_map = rdlp.parse_yaml(os.path.join(roslib.packages.get_pkg_dir("test_rosdep"),"test", "example_rosdep.yaml"))
00117 rdlp._insert_map(yaml_map, "example_yaml_path", False)
00118 parsed_output = {'zlib': 'zlib1g-dev', 'rosdep_test': 'librosdep_test1.37-dev'}
00119 self.assertEqual(parsed_output, rdlp.rosdep_map)
00120
00121 rdlp._insert_map(yaml_map, "example_yaml_path2", False)
00122 self.assertEqual(parsed_output, rdlp.rosdep_map)
00123
00124 def test_RosdepLookupPackage_failed_version_lookup(self):
00125 rdlp = self.rdlp
00126 yaml_map = rdlp.parse_yaml(os.path.join(roslib.packages.get_pkg_dir("test_rosdep"),"test", "example_rosdep.yaml"))
00127 rdlp._insert_map(yaml_map, "example_yaml_path", False)
00128 output = rdlp.lookup_rosdep("other_rosdep_test")
00129 self.assertEqual(output, False)
00130
00131 def test_RosdepLookupPackage_failed_os_lookup(self):
00132 rdlp = self.rdlp
00133 yaml_map = rdlp.parse_yaml(os.path.join(roslib.packages.get_pkg_dir("test_rosdep"),"test", "example_rosdep.yaml"))
00134 rdlp._insert_map(yaml_map, "example_yaml_path", False)
00135 output = rdlp.lookup_rosdep("no_os_rosdep_test")
00136 self.assertEqual(output, False)
00137
00138 def test_Rosdep_tripwire_robust(self):
00139 rd = rosdep.core.Rosdep(["rosdep"], "rosdep", robust=True)
00140 self.tripwire_impl(rd)
00141
00142 def test_Rosdep_tripwire(self):
00143 rd = rosdep.core.Rosdep(["rosdep"], "rosdep", robust=False)
00144 self.tripwire_impl(rd)
00145
00146 def tripwire_impl(self, rd):
00147 try:
00148 rd.check()
00149 except rosdep.core.RosdepException as ex:
00150 self.fail("test Rosdep check improperly Raised an exception.", ex)
00151 try:
00152 rd.what_needs(["boost"])
00153 except rosdep.core.RosdepException as ex:
00154 self.fail("test Rosdep what_needs improperly Raised an exception.", ex)
00155 try:
00156 rd.depdb(['rosdep'])
00157 except rosdep.core.RosdepException as ex:
00158 self.fail("test Rosdep depdb improperly Raised an exception.", ex)
00159 try:
00160 rd.where_defined(['boost'])
00161 except rosdep.core.RosdepException as ex:
00162 self.fail("test Rosdep where_defined improperly Raised an exception.", ex)
00163
00164
00165
00166
00167 if __name__ == '__main__':
00168 os.environ["ROSDEP_TEST_OS"] = "rosdep_test_os"
00169 rosunit.unitrun('test_rosdep', 'test_core', RosdepCoreTest, coverage_packages=['rosdep.core'])
00170