Beispiel #1
0
 def test_long_localname(self):
     "Should source choose shorter local-name"
     mock1 = PathSpec("/foo/bar/boo/far/bim")
     config = self._get_mock_config([mock1], '/foo/bar/boo/far')
     self.assertEqual(1, len(config.get_config_elements()))
     self.assertEqual('/foo/bar/boo/far/bim', config.get_config_elements()[0].get_local_name())
     self.assertEqual('/foo/bar/boo/far/bim', config.get_config_elements()[0].get_path())
Beispiel #2
0
    def test_config_merging_replace(self):
        git1 = PathSpec('foo', 'git', 'git/uri')
        svn1 = PathSpec('foo', 'svn', 'svn/uri')
        hg1 = PathSpec('foo', 'hg', 'hg/uri')
        bzr1 = PathSpec('foo', 'bzr', 'bzr/uri')
        config = self._get_mock_config([git1, svn1, hg1, bzr1], merge_strategy="MergeReplace")
        self.assertEqual(1, len(config.get_config_elements()))
        self.assertEqual('bzr', config.get_source()[0].get_scmtype())
        self.assertEqual('/install/path/bzr/uri', config.get_source()[0].get_uri())
        config = self._get_mock_config([git1, svn1, hg1, bzr1, git1], merge_strategy="MergeReplace")
        self.assertEqual(1, len(config.get_config_elements()))
        self.assertEqual('git', config.get_source()[0].get_scmtype())
        self.assertEqual('/install/path/git/uri', config.get_source()[0].get_uri())

        bzr1 = PathSpec('bar', 'bzr', 'bzr/uri')
        config = self._get_mock_config([git1, svn1, hg1, bzr1], merge_strategy="MergeReplace")
        self.assertEqual(2, len(config.get_config_elements()))
        self.assertEqual('hg', config.get_source()[0].get_scmtype())
        self.assertEqual('/install/path/hg/uri', config.get_source()[0].get_uri())
        self.assertEqual('bzr', config.get_source()[1].get_scmtype())
        self.assertEqual('/install/path/bzr/uri', config.get_source()[1].get_uri())
        config = self._get_mock_config([git1, svn1, hg1, bzr1, git1], merge_strategy="MergeReplace")
        self.assertEqual(2, len(config.get_config_elements()))
        self.assertEqual('git', config.get_source()[0].get_scmtype())
        self.assertEqual('/install/path/git/uri', config.get_source()[0].get_uri())
        self.assertEqual('bzr', config.get_source()[1].get_scmtype())
        self.assertEqual('/install/path/bzr/uri', config.get_source()[1].get_uri())
Beispiel #3
0
 def test_unnormalized_localname(self):
     "Should source normalize local-name"
     mock1 = PathSpec('foo/bar/..')
     config = self._get_mock_config([mock1])
     self.assertEqual(1, len(config.get_config_elements()))
     self.assertEqual('foo', config.get_config_elements()[0].get_local_name())
     self.assertEqual('/install/path/foo', config.get_config_elements()[0].get_path())
Beispiel #4
0
 def test_config_merging_kill_append(self):
     git1 = PathSpec('foo', 'git', 'git/uri')
     svn1 = PathSpec('foo', 'svn', 'svn/uri')
     hg1 = PathSpec('foo', 'hg', 'hg/uri')
     bzr1 = PathSpec('foo', 'bzr', 'bzr/uri')
     config = self._get_mock_config([git1, svn1, hg1, bzr1])
     self.assertEqual(1, len(config.get_config_elements()))
     self.assertEqual('bzr', config.get_source()[0].get_scmtype())
     self.assertEqual('/install/path/bzr/uri',
                      config.get_source()[0].get_uri())
     config = self._get_mock_config([git1, svn1, hg1, bzr1, git1])
     self.assertEqual(1, len(config.get_config_elements()))
     self.assertEqual('git', config.get_source()[0].get_scmtype())
     self.assertEqual('/install/path/git/uri',
                      config.get_source()[0].get_uri())
     bzr1 = PathSpec('bar', 'bzr', 'bzr/uri')
     config = self._get_mock_config([git1, svn1, hg1, bzr1])
     self.assertEqual(2, len(config.get_config_elements()))
     self.assertEqual('hg', config.get_source()[0].get_scmtype())
     self.assertEqual('/install/path/hg/uri',
                      config.get_source()[0].get_uri())
     self.assertEqual('bzr', config.get_source()[1].get_scmtype())
     self.assertEqual('/install/path/bzr/uri',
                      config.get_source()[1].get_uri())
     config = self._get_mock_config([git1, svn1, hg1, bzr1, git1])
     self.assertEqual(2, len(config.get_config_elements()))
     self.assertEqual('bzr', config.get_source()[0].get_scmtype())
     self.assertEqual('/install/path/bzr/uri',
                      config.get_source()[0].get_uri())
     self.assertEqual('git', config.get_source()[1].get_scmtype())
     self.assertEqual('/install/path/git/uri',
                      config.get_source()[1].get_uri())
Beispiel #5
0
 def test_cmd_remove(self):
     # rosinstall to create dir
     self.local_path = os.path.join(self.test_root_path, "ws32")
     cli = MultiprojectCLI(progname='multi_cli',
                           config_filename='.rosinstall',
                           allow_other_element=False)
     self.assertEqual(0, cli.cmd_init([self.local_path]))
     self.assertRaises(MultiProjectException, cli.cmd_merge,
                       self.local_path, [self.git_path, "-y"])
     self.assertRaises(MultiProjectException, cli.cmd_merge,
                       self.local_path, [self.hg_path, "-y"])
     cli = MultiprojectCLI(progname='multi_cli',
                           config_filename='.rosinstall',
                           allow_other_element=True)
     self.assertEqual(0,
                      cli.cmd_merge(self.local_path, [self.git_path, "-y"]))
     self.assertEqual(0, cli.cmd_merge(self.local_path,
                                       [self.hg_path, "-y"]))
     config = rosinstall.multiproject_cmd.get_config(
         basepath=self.local_path, config_filename='.rosinstall')
     self.assertEqual(len(config.get_config_elements()), 2)
     self.assertEqual(0, cli.cmd_remove(self.local_path, [self.git_path]))
     config = rosinstall.multiproject_cmd.get_config(
         basepath=self.local_path, config_filename='.rosinstall')
     self.assertEqual(len(config.get_config_elements()), 1)
Beispiel #6
0
 def test_config_simple1(self):
     mock1 = PathSpec('foo')
     config = self._get_mock_config([mock1])
     self.assertEqual(1, len(config.get_config_elements()))
     self.assertEqual('foo',
                      config.get_config_elements()[0].get_local_name())
     self.assertEqual('/install/path/foo',
                      config.get_config_elements()[0].get_path())
Beispiel #7
0
 def test_absolute_localname(self):
     mock1 = PathSpec('/foo/bim')
     config = self._get_mock_config([mock1],
                                    install_path='/foo/bar/ba/ra/baz/bam')
     self.assertEqual(1, len(config.get_config_elements()))
     self.assertEqual('/foo/bim',
                      config.get_config_elements()[0].get_local_name())
     self.assertEqual('/foo/bim',
                      config.get_config_elements()[0].get_path())
Beispiel #8
0
 def test_unnormalized_localname(self):
     "Should source normalize local-name"
     mock1 = PathSpec('foo/bar/..')
     config = self._get_mock_config([mock1])
     self.assertEqual(1, len(config.get_config_elements()))
     self.assertEqual('foo',
                      config.get_config_elements()[0].get_local_name())
     self.assertEqual('/install/path/foo',
                      config.get_config_elements()[0].get_path())
Beispiel #9
0
 def test_long_localname(self):
     "Should source choose shorter local-name"
     mock1 = PathSpec("/foo/bar/boo/far/bim")
     config = self._get_mock_config([mock1], '/foo/bar/boo/far')
     self.assertEqual(1, len(config.get_config_elements()))
     self.assertEqual('/foo/bar/boo/far/bim',
                      config.get_config_elements()[0].get_local_name())
     self.assertEqual('/foo/bar/boo/far/bim',
                      config.get_config_elements()[0].get_path())
Beispiel #10
0
 def test_cmd_remove(self):
     # rosinstall to create dir
     self.local_path = os.path.join(self.test_root_path, "ws32")
     cli = MultiprojectCLI(progname='multi_cli', config_filename='.rosinstall')
     self.assertEqual(0, cli.cmd_init([self.local_path]))
     self.assertEqual(0, cli.cmd_merge(self.local_path, [self.git_path, "-y"]))
     self.assertEqual(0, cli.cmd_merge(self.local_path, [self.hg_path, "-y"]))
     config = rosinstall.multiproject_cmd.get_config(basepath=self.local_path,
                                                     config_filename='.rosinstall')
     self.assertEqual(len(config.get_config_elements()), 2)
     self.assertEqual(0, cli.cmd_remove(self.local_path, [self.git_path]))
     config = rosinstall.multiproject_cmd.get_config(basepath=self.local_path,
                                                     config_filename='.rosinstall')
     self.assertEqual(len(config.get_config_elements()), 1)
Beispiel #11
0
 def test_mock_install_fail(self):
     test_root = tempfile.mkdtemp()
     try:
         # robust
         git1 = PathSpec('foo', 'git', 'git/uri', 'git.version')
         svn1 = PathSpec('foos', 'svn', 'svn/uri', '12345')
         hg1 = PathSpec('fooh', 'hg', 'hg/uri', 'hg.version')
         bzr1 = PathSpec('foob', 'bzr', 'bzr/uri', 'bzr.version')
         config = Config([git1, svn1, hg1, bzr1],
                         install_path=test_root,
                         config_filename=None,
                         extended_types={"svn": MockVcsConfigElement,
                                         "git": MockVcsConfigElement,
                                         "hg": MockVcsConfigElement,
                                         "bzr": MockVcsConfigElement})
         config.get_config_elements()[1].install_success = False
         rosinstall.multiproject_cmd.cmd_install_or_update(
             config, robust=True)
         try:
             rosinstall.multiproject_cmd.cmd_install_or_update(
                 config, robust=False)
             self.fail("expected Exception")
         except MultiProjectException:
             pass
     finally:
         shutil.rmtree(test_root)
Beispiel #12
0
 def test_config_simple3(self):
     git1 = PathSpec('foo', 'git', 'git/uri', 'git.version')
     svn1 = PathSpec('foos', 'svn', 'svn/uri', '12345')
     bzr1 = PathSpec('foob', 'bzr', 'bzr/uri', 'bzr.version')
     hg1 = PathSpec('fooh', 'hg', 'hg/uri', 'hg.version')
     config = self._get_mock_config([git1, svn1, hg1, bzr1])
     self.assertEqual(4, len(config.get_config_elements()))
Beispiel #13
0
 def test_config_simple3(self):
     git1 = PathSpec('foo', 'git', 'git/uri', 'git.version')
     svn1 = PathSpec('foos', 'svn', 'svn/uri', '12345')
     bzr1 = PathSpec('foob', 'bzr', 'bzr/uri', 'bzr.version')
     hg1 = PathSpec('fooh', 'hg', 'hg/uri', 'hg.version')
     config = self._get_mock_config([git1, svn1, hg1, bzr1])
     self.assertEqual(4, len(config.get_config_elements()))
Beispiel #14
0
 def test_mock_install_fail(self):
     test_root = tempfile.mkdtemp()
     try:
         # robust
         git1 = PathSpec('foo', 'git', 'git/uri', 'git.version')
         svn1 = PathSpec('foos', 'svn', 'svn/uri', '12345')
         hg1 = PathSpec('fooh', 'hg', 'hg/uri', 'hg.version')
         bzr1 = PathSpec('foob', 'bzr', 'bzr/uri', 'bzr.version')
         config = Config(
             [git1, svn1, hg1, bzr1], test_root, None, {
                 "svn": MockVcsConfigElement,
                 "git": MockVcsConfigElement,
                 "hg": MockVcsConfigElement,
                 "bzr": MockVcsConfigElement
             })
         config.get_config_elements()[1].install_success = False
         rosinstall.multiproject_cmd.cmd_install_or_update(config,
                                                           robust=True)
         try:
             rosinstall.multiproject_cmd.cmd_install_or_update(config,
                                                               robust=False)
             self.fail("expected Exception")
         except MultiProjectException:
             pass
     finally:
         shutil.rmtree(test_root)
Beispiel #15
0
 def test_config_simple2(self):
     git1 = PathSpec('foo', 'git', 'git/uri')
     svn1 = PathSpec('foos', 'svn', 'svn/uri')
     hg1 = PathSpec('fooh', 'hg', 'hg/uri')
     bzr1 = PathSpec('foob', 'bzr', 'bzr/uri')
     config = self._get_mock_config([git1, svn1, hg1, bzr1])
     self.assertEqual(4, len(config.get_config_elements()))
     self.assertEqual('foo', config.get_config_elements()[0].get_local_name())
     self.assertEqual('/install/path/foo', config.get_config_elements()[0].get_path())
     self.assertEqual('git', config.get_source()[0].get_scmtype())
     self.assertEqual('/install/path/git/uri', config.get_source()[0].get_uri())
     self.assertEqual('svn', config.get_source()[1].get_scmtype())
     self.assertEqual('/install/path/svn/uri', config.get_source()[1].get_uri())
     self.assertEqual('hg', config.get_source()[2].get_scmtype())
     self.assertEqual('/install/path/hg/uri', config.get_source()[2].get_uri())
     self.assertEqual('bzr', config.get_source()[3].get_scmtype())
     self.assertEqual('/install/path/bzr/uri', config.get_source()[3].get_uri())
Beispiel #16
0
    def test_cmd_add(self):
        # rosinstall to create dir
        self.local_path = os.path.join(self.test_root_path, "ws33")
        cli = MultiprojectCLI(progname='multi_cli',
                              config_filename='.rosinstall')
        simple_rel_rosinstall = os.path.join(self.test_root_path,
                                             "simple_rel3.rosinstall")
        _create_yaml_file([
            _create_config_elt_dict(scmtype="git",
                                    uri=os.path.join(self.test_root_path,
                                                     "ros"),
                                    localname='ros')
        ], simple_rel_rosinstall)
        self.assertEqual(
            0, cli.cmd_init([self.local_path, simple_rel_rosinstall]))
        config = rosinstall.multiproject_cmd.get_config(
            basepath=self.local_path, config_filename='.rosinstall')
        self.assertEqual(1, len(config.get_config_elements()))
        self.assertEqual(
            'git',
            config.get_config_elements()[0].get_path_spec().get_scmtype())

        rosinstall.multiproject_cmd.add_uris(config, [self.local_path])
        self.assertEqual(len(config.get_config_elements()), 1, config)
        self.assertEqual(
            'git',
            config.get_config_elements()[0].get_path_spec().get_scmtype())

        rosinstall.multiproject_cmd.add_uris(
            config, [os.path.join(self.local_path, '.rosinstall')])
        self.assertEqual(len(config.get_config_elements()), 1, config)
        self.assertEqual(
            'git',
            config.get_config_elements()[0].get_path_spec().get_scmtype())
Beispiel #17
0
 def test_config_simple2(self):
     git1 = PathSpec('foo', 'git', 'git/uri')
     svn1 = PathSpec('foos', 'svn', 'svn/uri')
     hg1 = PathSpec('fooh', 'hg', 'hg/uri')
     bzr1 = PathSpec('foob', 'bzr', 'bzr/uri')
     config = self._get_mock_config([git1, svn1, hg1, bzr1])
     self.assertEqual(4, len(config.get_config_elements()))
     self.assertEqual('foo',
                      config.get_config_elements()[0].get_local_name())
     self.assertEqual('/install/path/foo',
                      config.get_config_elements()[0].get_path())
     self.assertEqual('git', config.get_source()[0].get_scmtype())
     self.assertEqual('/install/path/git/uri',
                      config.get_source()[0].get_uri())
     self.assertEqual('svn', config.get_source()[1].get_scmtype())
     self.assertEqual('/install/path/svn/uri',
                      config.get_source()[1].get_uri())
     self.assertEqual('hg', config.get_source()[2].get_scmtype())
     self.assertEqual('/install/path/hg/uri',
                      config.get_source()[2].get_uri())
     self.assertEqual('bzr', config.get_source()[3].get_scmtype())
     self.assertEqual('/install/path/bzr/uri',
                      config.get_source()[3].get_uri())
Beispiel #18
0
 def test_init(self):
     yaml = []
     install_path = '/install/path'
     config_filename = '.filename'
     config = Config(yaml, install_path, config_filename)
     self.assertEqual(install_path, config.get_base_path())
     self.assertEqual([], config.get_config_elements())
     config = Config([
         PathSpec("foo"),
         PathSpec(os.path.join("test", "example_dirs", "ros_comm")),
         PathSpec(os.path.join("test", "example_dirs", "ros")),
         PathSpec(os.path.join("test", "example_dirs", "roscpp")),
         PathSpec("bar")
     ], ".", None)
     self.assertEqual(os.path.abspath('.'), config.get_base_path())
Beispiel #19
0
 def test_init(self):
     yaml = []
     install_path = '/install/path'
     config_filename = '.filename'
     config = Config(yaml, install_path, config_filename)
     self.assertEqual(install_path, config.get_base_path())
     self.assertEqual([], config.get_config_elements())
     config = Config([PathSpec("foo"),
                      PathSpec(os.path.join("test", "example_dirs", "ros_comm")),
                      PathSpec(os.path.join("test", "example_dirs", "ros")),
                      PathSpec(os.path.join("test", "example_dirs", "roscpp")),
                      PathSpec("bar")],
                     ".",
                     None)
     self.assertEqual(os.path.abspath('.'), config.get_base_path())
Beispiel #20
0
    def test_config_simple1_with_setupfile(self):
        mock1 = PathSpec('setup.sh', tags='setup-file')
        config = self._get_mock_config([mock1])
        self.assertEqual(1, len(config.get_config_elements()))
        self.assertEqual('setup.sh', config.get_config_elements()[0].get_local_name())
        self.assertEqual('/install/path/setup.sh', config.get_config_elements()[0].get_path())

        mock1 = PathSpec('/foo')
        mock2 = PathSpec('/opt/setup.sh', tags='setup-file')
        mock3 = PathSpec('/bar')
        config = self._get_mock_config([mock1, mock2, mock3])
        self.assertEqual(3, len(config.get_config_elements()))
        self.assertEqual('/opt/setup.sh', config.get_config_elements()[1].get_local_name())
        self.assertEqual('/opt/setup.sh', config.get_config_elements()[1].get_path())
Beispiel #21
0
    def test_config_realfolders(self):
        try:
            root_path = tempfile.mkdtemp()
            share_path = os.path.join(root_path, "share")
            os.makedirs(share_path)
            ros_path = os.path.join(share_path, "ros")
            os.makedirs(ros_path)

            p1 = PathSpec('share')
            p2 = PathSpec('share/ros')
            config = self._get_mock_config([p1, p2])
            self.assertEqual(2, len(config.get_config_elements()))
            try:
                p1 = PathSpec('share', 'git', 'git/uri', 'git.version')
                p2 = PathSpec('share/ros', 'hg', 'hg/uri', 'hg.version')
                config = self._get_mock_config([p1, p2])
                self.fail("expected overlap Exception")
            except MultiProjectException:
                pass
            try:
                p1 = PathSpec('share', 'git', 'git/uri', 'git.version')
                p2 = PathSpec('share/ros', 'hg', 'hg/uri', 'hg.version')
                config = self._get_mock_config([p2, p1])
                self.fail("expected overlap Exception")
            except MultiProjectException:
                pass
            try:
                p1 = PathSpec('share', 'git', 'git/uri', 'git.version')
                p2 = PathSpec('share/ros')
                config = self._get_mock_config([p2, p1])
                self.fail("expected overlap Exception")
            except MultiProjectException:
                pass
            try:
                p1 = PathSpec('share', 'git', 'git/uri', 'git.version')
                p2 = PathSpec('share/ros')
                config = self._get_mock_config([p1, p2])
                self.fail("expected overlap Exception")
            except MultiProjectException:
                pass
        finally:
            shutil.rmtree(root_path)
Beispiel #22
0
    def test_config_realfolders(self):
        try:
            root_path = tempfile.mkdtemp()
            share_path = os.path.join(root_path, "share")
            os.makedirs(share_path)
            ros_path = os.path.join(share_path, "ros")
            os.makedirs(ros_path)

            p1 = PathSpec('share')
            p2 = PathSpec('share/ros')
            config = self._get_mock_config([p1, p2])
            self.assertEqual(2, len(config.get_config_elements()))
            try:
                p1 = PathSpec('share', 'git', 'git/uri', 'git.version')
                p2 = PathSpec('share/ros', 'hg', 'hg/uri', 'hg.version')
                config = self._get_mock_config([p1, p2])
                self.fail("expected overlap Exception")
            except MultiProjectException:
                pass
            try:
                p1 = PathSpec('share', 'git', 'git/uri', 'git.version')
                p2 = PathSpec('share/ros', 'hg', 'hg/uri', 'hg.version')
                config = self._get_mock_config([p2, p1])
                self.fail("expected overlap Exception")
            except MultiProjectException:
                pass
            try:
                p1 = PathSpec('share', 'git', 'git/uri', 'git.version')
                p2 = PathSpec('share/ros')
                config = self._get_mock_config([p2, p1])
                self.fail("expected overlap Exception")
            except MultiProjectException:
                pass
            try:
                p1 = PathSpec('share', 'git', 'git/uri', 'git.version')
                p2 = PathSpec('share/ros')
                config = self._get_mock_config([p1, p2])
                self.fail("expected overlap Exception")
            except MultiProjectException:
                pass
        finally:
            shutil.rmtree(root_path)
Beispiel #23
0
    def test_config_simple1_with_setupfile(self):
        mock1 = PathSpec('setup.sh', tags='setup-file')
        config = self._get_mock_config([mock1])
        self.assertEqual(1, len(config.get_config_elements()))
        self.assertEqual('setup.sh',
                         config.get_config_elements()[0].get_local_name())
        self.assertEqual('/install/path/setup.sh',
                         config.get_config_elements()[0].get_path())

        mock1 = PathSpec('/foo')
        mock2 = PathSpec('/opt/setup.sh', tags='setup-file')
        mock3 = PathSpec('/bar')
        config = self._get_mock_config([mock1, mock2, mock3])
        self.assertEqual(3, len(config.get_config_elements()))
        self.assertEqual('/opt/setup.sh',
                         config.get_config_elements()[1].get_local_name())
        self.assertEqual('/opt/setup.sh',
                         config.get_config_elements()[1].get_path())
Beispiel #24
0
    def test_cmd_add(self):
        # rosinstall to create dir
        self.local_path = os.path.join(self.test_root_path, "ws33")
        cli = MultiprojectCLI(progname='multi_cli', config_filename='.rosinstall')
        simple_rel_rosinstall = os.path.join(self.test_root_path, "simple_rel3.rosinstall")
        _create_yaml_file([_create_config_elt_dict(scmtype="git",
                                                   uri=os.path.join(self.test_root_path, "ros"),
                                                   localname='ros')],
                          simple_rel_rosinstall)
        self.assertEqual(0, cli.cmd_init([self.local_path, simple_rel_rosinstall]))
        config = rosinstall.multiproject_cmd.get_config(basepath=self.local_path,
                                                        config_filename='.rosinstall')
        self.assertEqual(1, len(config.get_config_elements()))
        self.assertEqual('git', config.get_config_elements()[0].get_path_spec().get_scmtype())

        rosinstall.multiproject_cmd.add_uris(config, [self.local_path])
        self.assertEqual(len(config.get_config_elements()), 1, config)
        self.assertEqual('git', config.get_config_elements()[0].get_path_spec().get_scmtype())

        rosinstall.multiproject_cmd.add_uris(config, [os.path.join(self.local_path, '.rosinstall')])
        self.assertEqual(len(config.get_config_elements()), 1, config)
        self.assertEqual('git', config.get_config_elements()[0].get_path_spec().get_scmtype())
Beispiel #25
0
 def test_equivalent_localname(self):
     "Entries have equivalent local name"
     mock1 = PathSpec('foo', 'git', 'git/uri')
     mock2 = PathSpec('./foo/bar/..', 'hg', 'hg/uri')
     config = self._get_mock_config([mock1, mock2])
     self.assertEqual(1, len(config.get_config_elements()))
Beispiel #26
0
 def test_double_localname(self):
     "Entries have same local name"
     mock1 = PathSpec('foo', 'git', 'git/uri')
     mock2 = PathSpec('foo', 'hg', 'hg/uri')
     config = self._get_mock_config([mock1, mock2])
     self.assertEqual(1, len(config.get_config_elements()))
Beispiel #27
0
 def test_equivalent_entry(self):
     "Should source be rewritten without duplicates"
     mock1 = PathSpec('foo')
     mock2 = PathSpec('./foo')
     config = self._get_mock_config([mock1, mock2])
     self.assertEqual(1, len(config.get_config_elements()))
Beispiel #28
0
 def test_config_simple1(self):
     mock1 = PathSpec('foo')
     config = self._get_mock_config([mock1])
     self.assertEqual(1, len(config.get_config_elements()))
     self.assertEqual('foo', config.get_config_elements()[0].get_local_name())
     self.assertEqual('/install/path/foo', config.get_config_elements()[0].get_path())
Beispiel #29
0
 def test_double_localname(self):
     "Entries have same local name"
     mock1 = PathSpec('foo', 'git', 'git/uri')
     mock2 = PathSpec('foo', 'hg', 'hg/uri')
     config = self._get_mock_config([mock1, mock2])
     self.assertEqual(1, len(config.get_config_elements()))
Beispiel #30
0
 def test_remove(self):
     git1 = PathSpec('foo', 'git', 'git/uri', 'git.version')
     svn1 = PathSpec('foos', 'svn', 'svn/uri', '12345')
     hg1 = PathSpec('fooh', 'hg', 'hg/uri', 'hg.version')
     bzr1 = PathSpec('foob', 'bzr', 'bzr/uri', 'bzr.version')
     config = self._get_mock_config([git1, svn1, hg1, bzr1])
     self.assertEqual(4, len(config.get_config_elements()))
     self.assertFalse(config.remove_element(None))
     self.assertFalse(config.remove_element('bar'))
     self.assertEqual(4, len(config.get_config_elements()))
     self.assertTrue(config.remove_element('foo'))
     self.assertEqual(3, len(config.get_config_elements()))
     self.assertEqual('/install/path/foos',
                      config.get_config_elements()[0].get_path())
     self.assertEqual('/install/path/fooh',
                      config.get_config_elements()[1].get_path())
     self.assertEqual('/install/path/foob',
                      config.get_config_elements()[2].get_path())
     self.assertTrue(config.remove_element('fooh'))
     self.assertEqual(2, len(config.get_config_elements()))
     self.assertEqual('/install/path/foos',
                      config.get_config_elements()[0].get_path())
     self.assertEqual('/install/path/foob',
                      config.get_config_elements()[1].get_path())
     self.assertTrue(config.remove_element('foos'))
     self.assertEqual(1, len(config.get_config_elements()))
     self.assertTrue(config.remove_element('foob'))
     self.assertEqual(0, len(config.get_config_elements()))
Beispiel #31
0
 def test_remove(self):
     git1 = PathSpec('foo', 'git', 'git/uri', 'git.version')
     svn1 = PathSpec('foos', 'svn', 'svn/uri', '12345')
     hg1 = PathSpec('fooh', 'hg', 'hg/uri', 'hg.version')
     bzr1 = PathSpec('foob', 'bzr', 'bzr/uri', 'bzr.version')
     config = self._get_mock_config([git1, svn1, hg1, bzr1])
     self.assertEqual(4, len(config.get_config_elements()))
     self.assertFalse(config.remove_element(None))
     self.assertFalse(config.remove_element('bar'))
     self.assertEqual(4, len(config.get_config_elements()))
     self.assertTrue(config.remove_element('foo'))
     self.assertEqual(3, len(config.get_config_elements()))
     self.assertEqual('/install/path/foos', config.get_config_elements()[0].get_path())
     self.assertEqual('/install/path/fooh', config.get_config_elements()[1].get_path())
     self.assertEqual('/install/path/foob', config.get_config_elements()[2].get_path())
     self.assertTrue(config.remove_element('fooh'))
     self.assertEqual(2, len(config.get_config_elements()))
     self.assertEqual('/install/path/foos', config.get_config_elements()[0].get_path())
     self.assertEqual('/install/path/foob', config.get_config_elements()[1].get_path())
     self.assertTrue(config.remove_element('foos'))
     self.assertEqual(1, len(config.get_config_elements()))
     self.assertTrue(config.remove_element('foob'))
     self.assertEqual(0, len(config.get_config_elements()))
Beispiel #32
0
 def test_equivalent_localname(self):
     "Entries have equivalent local name"
     mock1 = PathSpec('foo', 'git', 'git/uri')
     mock2 = PathSpec('./foo/bar/..', 'hg', 'hg/uri')
     config = self._get_mock_config([mock1, mock2])
     self.assertEqual(1, len(config.get_config_elements()))
Beispiel #33
0
 def test_absolute_localname(self):
     mock1 = PathSpec('/foo/bim')
     config = self._get_mock_config([mock1], install_path='/foo/bar/ba/ra/baz/bam')
     self.assertEqual(1, len(config.get_config_elements()))
     self.assertEqual('/foo/bim', config.get_config_elements()[0].get_local_name())
     self.assertEqual('/foo/bim', config.get_config_elements()[0].get_path())
Beispiel #34
0
 def test_equivalent_entry(self):
     "Should source be rewritten without duplicates"
     mock1 = PathSpec('foo')
     mock2 = PathSpec('./foo')
     config = self._get_mock_config([mock1, mock2])
     self.assertEqual(1, len(config.get_config_elements()))