Exemplo n.º 1
0
    def test_try_locate_returns_cwd_if_cwd_is_a_workspace(self):
        cwd = os.path.join(tempfile.mkdtemp(), "ws")
        workspace_generator.create(cwd)

        ws_path = workspace.try_locate(cwd)

        self.assertEqual(os.path.realpath(cwd), os.path.realpath(ws_path))
Exemplo n.º 2
0
    def test_try_locate_returns_env_cwd_if_env_cwd_is_a_workspace(self):
        cwd = os.path.join(tempfile.mkdtemp(), "wd")
        workspace_generator.create(cwd)

        with TemporaryEnv():
            os.chdir(cwd)
            ws_path = workspace.try_locate()
            self.assertEqual(os.path.realpath(cwd), os.path.realpath(ws_path))
Exemplo n.º 3
0
    def test_try_locate_returns_LOR_HOME_if_it_is_set_in_env(self):
        cwd = os.path.join(tempfile.mkdtemp(), "wd")
        workspace_generator.create(cwd)

        with TemporaryEnv():
            os.environ[lor._constants.WORKSPACE_ENV_VARNAME] = cwd

            ws_path = workspace.try_locate()
            self.assertEqual(os.path.realpath(cwd), os.path.realpath(ws_path))
Exemplo n.º 4
0
    def test_try_locate_returns_cwd_if_workspace_is_a_parent_of_cwd(self):
        cwd = os.path.join(tempfile.mkdtemp(), "ws")
        workspace_generator.create(cwd)
        some_subdir = os.path.join(cwd, 'some', 'subdir', 'in', 'ws')
        os.makedirs(some_subdir)

        ws_path = workspace.try_locate(some_subdir)

        self.assertEqual(os.path.realpath(cwd), os.path.realpath(ws_path))
Exemplo n.º 5
0
def launch(out_of_workspace_subcommands=None, workspace_subcommands=None):
    """Launch LoR top-level CLI

    :param out_of_workspace_subcommands: A dict of <name: `CliCommand`>s to use when outside a workspace
    :param workspace_subcommands: A dict of <name: `CliCommand`>s to use when inside a workspace
    """
    if out_of_workspace_subcommands is None:
        out_of_workspace_subcommands = get_default_out_of_workspace_subcommands(
        )

    if workspace_subcommands is None:
        workspace_subcommands = get_default_workspace_subcommands()

    if workspace.try_locate() is not None:
        commands = workspace_subcommands
    else:
        commands = out_of_workspace_subcommands

    __launch_cli(commands)
Exemplo n.º 6
0
 def test_try_locate_returns_none_if_lor_home_is_not_set_and_cwd_is_not_a_workspace(
         self):
     cwd = tempfile.mkdtemp()
     self.assertIsNone(workspace.try_locate(cwd))