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