def test_print_table_list(): model_configurations = [ get_model_configuration(CONFIG_PARTIAL_INFO, profile=testing) ] setups = [ get_setup(obtain_id(SETUP_PARTIAL_INFO), profile=testing), get_setup(SETUP_FULL_INFO, profile=testing) ] print_table_list(setups) print_table_list(model_configurations)
def test_print_data_property_table(): setups = [ get_setup(obtain_id(SETUP_PARTIAL_INFO), profile=testing), get_setup(SETUP_FULL_INFO, profile=testing) ] model_configurations = [ get_model_configuration(CONFIG_PARTIAL_INFO, profile=testing) ] for setup in setups: print_data_property_table(setup) for model_configuration in model_configurations: print_data_property_table(model_configuration)
def run(name, interactive, profile, data): if not data or not Path(data).exists(): data = None else: data = Path(data) try: config = get_model_configuration(name, profile=profile) except ApiException as e: click.secho("{}".format(e.reason)) exit(0) click.clear() if "ModelConfigurationSetup" in config.type: resource = get_setup(name, profile=profile) elif "ModelConfiguration" in config.type or "DataTransformation": resource = get_model_configuration(name, profile=profile) try: show_model_configuration_details(resource) except AttributeError as e: click.secho("Unable to run it: {}".format(str(e)), fg="red") exit(1) try: verify_input_parameters(resource, interactive, data, profile) except ValueError as e: click.secho("Unable to run. Please use interactive mode", fg="yellow") exit(1) try: if interactive and click.confirm( "Do you want to edit the parameters?"): edit_parameters(resource, interactive) except ValueError as e: click.secho("Unable to run. Please use interactive mode", fg="yellow") exit(1) run_method_setup(resource, interactive, data)
def setup_show(name, profile): try: _setup = get_setup(name, profile=profile) except ApiException as e: click.secho("{}".format(e.reason)) exit(1) try: show_model_configuration_details(_setup) except AttributeError as e: click.secho("This setup is not executable.\n".format(e), fg="red")
def test_show_model_configuration_details(): model_configurations = [ get_model_configuration(CONFIG_PARTIAL_INFO, profile=testing) ] setups = [ get_setup(obtain_id(SETUP_PARTIAL_INFO), profile=testing), get_setup(SETUP_FULL_INFO, profile=testing) ] for setup in setups: try: show_model_configuration_details(setup) except AttributeError: pass for model_configuration in model_configurations: try: show_model_configuration_details(model_configuration) except AttributeError: pass
def test_edit_parameters(monkeypatch): runner = CliRunner() setup = get_setup(SETUP_FULL_INFO, profile=testing) monkeypatch.setattr('sys.stdin', io.StringIO("1\n2\n3\n\n\n\n\n\n\n")) new_setup = edit_parameters(setup, True) assert new_setup.has_parameter[0].has_default_value == ['1']
def test_verify_input_parameters(): runner = CliRunner() partial_setup = get_setup(SETUP_FULL_INFO, profile=testing) assert verify_input_parameters(partial_setup, False, None) == partial_setup
def test_build_input(tmp_path): d = tmp_path / "sub" setup = get_setup("hand_v2_raster", profile=testing) with pytest.raises(ValueError, match=r".* has not a fixedResource"): build_input(setup.has_input, d)