コード例 #1
0
 def test_config_set(self):
     new_workspace = f"{uuid4()}"
     new_workspace_namespace = f"{uuid4()}"
     new_copy_progress_indicator_type = "log"
     with NamedTemporaryFile() as tf:
         with CLIConfigOverride(None, None, tf.name):
             CLIConfig.write()
             args = argparse.Namespace(workspace=new_workspace)
             terra_notebook_utils.cli.commands.config.set_config_workspace(
                 args)
             args = argparse.Namespace(
                 workspace_namespace=new_workspace_namespace)
             terra_notebook_utils.cli.commands.config.set_config_workspace_namespace(
                 args)
             args = argparse.Namespace(copy_progress_indicator_type=
                                       new_copy_progress_indicator_type)
             terra_notebook_utils.cli.commands.config.set_indicator_type(
                 args)
             with open(tf.name) as fh:
                 data = json.loads(fh.read())
             self.assertEqual(
                 data,
                 dict(workspace=new_workspace,
                      workspace_namespace=new_workspace_namespace,
                      copy_progress_indicator_type="log"))
コード例 #2
0
 def _test_cmd(self, cmd: Callable, **kwargs):
     with NamedTemporaryFile() as tf:
         with CLIConfigOverride(WORKSPACE_NAME, WORKSPACE_NAMESPACE, tf.name):
             CLIConfig.write()
             args = argparse.Namespace(**dict(**self.common_kwargs, **kwargs))
             out = io.StringIO()
             with redirect_stdout(out):
                 cmd(args)
             return out.getvalue().strip()
コード例 #3
0
def set_indicator_type(args: argparse.Namespace):
    """
    Set the indicator type for DRS copy operations.

    When 'copy-progress-indicator-type' is set to 'auto', terra-notebook-utils chooses the most appropriate
    indicator type for copy operations.
    """
    CLIConfig.info[
        "copy_progress_indicator_type"] = args.copy_progress_indicator_type
    CLIConfig.write()
コード例 #4
0
 def test_config_print(self):
     workspace = f"{uuid4()}"
     workspace_namespace = f"{uuid4()}"
     copy_progress_indicator_type = "auto"
     with NamedTemporaryFile() as tf:
         with CLIConfigOverride(workspace, workspace_namespace, tf.name):
             CLIConfig.write()
             args = argparse.Namespace()
             out = io.StringIO()
             with redirect_stdout(out):
                 terra_notebook_utils.cli.commands.config.config_print(args)
             data = json.loads(out.getvalue())
             self.assertEqual(
                 data,
                 dict(workspace=workspace,
                      workspace_namespace=workspace_namespace,
                      copy_progress_indicator_type=
                      copy_progress_indicator_type))
コード例 #5
0
def set_config_workspace_namespace(args: argparse.Namespace):
    """
    Set workspace namespace for cli commands
    """
    CLIConfig.info["workspace_namespace"] = args.workspace_namespace
    CLIConfig.write()