def test_cmd_remove(self): # wstool 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 = wstool.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 = wstool.multiproject_cmd.get_config( basepath=self.local_path, config_filename='.rosinstall') self.assertEqual(len(config.get_config_elements()), 1)
def test_init_parallel(self): self.local_path = os.path.join(self.test_root_path, "ws31") cli = MultiprojectCLI(progname='multi_cli', config_filename='.rosinstall') self.assertEqual( 0, cli.cmd_init( [self.local_path, self.simple_rosinstall, "--parallel=5"])) self.assertTrue( os.path.exists(os.path.join(self.local_path, '.rosinstall'))) self.assertTrue( os.path.exists(os.path.join(self.local_path, 'gitrepo'))) self.assertFalse( os.path.exists(os.path.join(self.local_path, 'hgrepo'))) self.assertEqual( 0, cli.cmd_merge(self.local_path, [self.simple_changed_vcs_rosinstall, "-y"])) self.assertTrue( os.path.exists(os.path.join(self.local_path, 'gitrepo'))) self.assertFalse( os.path.exists(os.path.join(self.local_path, 'hgrepo'))) self.assertEqual(0, cli.cmd_update(self.local_path, ["--parallel=5"])) self.assertTrue( os.path.exists(os.path.join(self.local_path, 'gitrepo'))) self.assertTrue(os.path.exists(os.path.join(self.local_path, 'hgrepo')))
def test_merge_dash(self): self.local_path = os.path.join(self.test_root_path, "ws35") cli = MultiprojectCLI(progname='multi_cli', config_filename='.rosinstall') self.assertEqual( 0, cli.cmd_init( [self.local_path, self.simple_rosinstall, "--parallel=5"])) self.assertTrue( os.path.exists(os.path.join(self.local_path, '.rosinstall'))) self.assertTrue( os.path.exists(os.path.join(self.local_path, 'gitrepo'))) self.assertFalse( os.path.exists(os.path.join(self.local_path, 'hgrepo'))) try: backup = sys.stdin with open(self.simple_changed_vcs_rosinstall, 'r') as fhand: contents = fhand.read() sys.stdin = Mock() sys.stdin.readlines.return_value = contents self.assertEqual(0, cli.cmd_merge(self.local_path, ["-"])) finally: sys.stdin = backup self.assertTrue( os.path.exists(os.path.join(self.local_path, 'gitrepo'))) self.assertFalse( os.path.exists(os.path.join(self.local_path, 'hgrepo'))) self.assertEqual(0, cli.cmd_update(self.local_path, ["--parallel=5"])) self.assertTrue( os.path.exists(os.path.join(self.local_path, 'gitrepo'))) self.assertTrue(os.path.exists(os.path.join(self.local_path, 'hgrepo')))
def test_cmd_remove(self): # wstool 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 = wstool.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 = wstool.multiproject_cmd.get_config(basepath=self.local_path, config_filename='.rosinstall') self.assertEqual(len(config.get_config_elements()), 1)
def test_init_parallel(self): self.local_path = os.path.join(self.test_root_path, "ws31") cli = MultiprojectCLI(progname='multi_cli', config_filename='.rosinstall') self.assertEqual(0, cli.cmd_init([self.local_path, self.simple_rosinstall, "--parallel=5"])) self.assertTrue(os.path.exists(os.path.join(self.local_path, '.rosinstall'))) self.assertTrue(os.path.exists(os.path.join(self.local_path, 'gitrepo'))) self.assertFalse(os.path.exists(os.path.join(self.local_path, 'hgrepo'))) self.assertEqual(0, cli.cmd_merge(self.local_path, [self.simple_changed_vcs_rosinstall, "-y"])) self.assertTrue(os.path.exists(os.path.join(self.local_path, 'gitrepo'))) self.assertFalse(os.path.exists(os.path.join(self.local_path, 'hgrepo'))) self.assertEqual(0, cli.cmd_update(self.local_path, ["--parallel=5"])) self.assertTrue(os.path.exists(os.path.join(self.local_path, 'gitrepo'))) self.assertTrue(os.path.exists(os.path.join(self.local_path, 'hgrepo')))
def test_cmd_info(self): self.local_path = os.path.join(self.test_root_path, "ws_test_cmd_info") cli = MultiprojectCLI(progname='multi_cli', config_filename='.rosinstall') self.assertEqual(0, cli.cmd_info(self.local_path, [])) self.assertEqual(0, cli.cmd_info(self.local_path, ['--root'])) self.assertEqual(0, cli.cmd_info(self.local_path, ['--yaml'])) self.assertEqual(0, cli.cmd_info(self.local_path, ['--untracked'])) self.assertEqual(0, cli.cmd_init([self.local_path, self.simple_rosinstall, "--parallel=5"])) self.assertEqual(0, cli.cmd_merge(self.local_path, [self.simple_changed_vcs_rosinstall, "-y"])) self.assertEqual(0, cli.cmd_info(self.local_path, [])) self.assertEqual(0, cli.cmd_info(self.local_path, ['gitrepo'])) self.assertEqual(0, cli.cmd_info(self.local_path, ['hgrepo'])) self.assertEqual(0, cli.cmd_info(self.local_path, ['--fetch'])) self.assertEqual(0, cli.cmd_info(self.local_path, ['gitrepo', '--fetch'])) self.assertEqual(0, cli.cmd_info(self.local_path, ['hgrepo', '--fetch']))
def test_merge_dash(self): self.local_path = os.path.join(self.test_root_path, "ws35") cli = MultiprojectCLI(progname='multi_cli', config_filename='.rosinstall') self.assertEqual(0, cli.cmd_init([self.local_path, self.simple_rosinstall, "--parallel=5"])) self.assertTrue(os.path.exists(os.path.join(self.local_path, '.rosinstall'))) self.assertTrue(os.path.exists(os.path.join(self.local_path, 'gitrepo'))) self.assertFalse(os.path.exists(os.path.join(self.local_path, 'hgrepo'))) try: backup = sys.stdin with open(self.simple_changed_vcs_rosinstall, 'r') as fhand: contents = fhand.read() sys.stdin = Mock() sys.stdin.readlines.return_value = contents self.assertEqual(0, cli.cmd_merge(self.local_path, ["-"])) finally: sys.stdin = backup self.assertTrue(os.path.exists(os.path.join(self.local_path, 'gitrepo'))) self.assertFalse(os.path.exists(os.path.join(self.local_path, 'hgrepo'))) self.assertEqual(0, cli.cmd_update(self.local_path, ["--parallel=5"])) self.assertTrue(os.path.exists(os.path.join(self.local_path, 'gitrepo'))) self.assertTrue(os.path.exists(os.path.join(self.local_path, 'hgrepo')))