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"))
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()
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()
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))
def set_config_workspace_namespace(args: argparse.Namespace): """ Set workspace namespace for cli commands """ CLIConfig.info["workspace_namespace"] = args.workspace_namespace CLIConfig.write()