def test_set_output_directory(self): # 1. Set up initial test dat project = None value = "test/subdir" # 2. Run test try: project = Project() project.set_output_directory(value) except Exception as e: pytest.fail("No exception expected, but thrown: {}".format(str(e)))
def test_print_configuration(self): # 1. Set up initial test dat project = None value = None # 2. Run test try: project = Project() value = project.print_configuration() except Exception as e: pytest.fail("No exception expected, but thrown: {}".format(str(e))) # 3. Verify final expectations assert value is not None
def test_set_input_file(self): # 1. Set up initial test dat project = None value = "RandomString" # 2. Run test try: project = Project() project.set_input_file("CrossSectionLocationFile", value) except Exception as e: pytest.fail("No exception expected, but thrown: {}".format(str(e))) # 3. Verify final expectations assert project.get_input_file("CrossSectionLocationFile") == value
def test_set_parameter(self): # 1. Set up initial test dat project = None value = 150 # 2. Run test try: project = Project() project.set_parameter("LakeTimeSteps", value) except Exception as e: pytest.fail("No exception expected, but thrown: {}".format(str(e))) # 3. Verify final expectations assert project.get_parameter("LakeTimeSteps") == value
def test_if_get_nonexisting_parameter_then_no_exception(self): # 1. Set up initial test dat project = None value = None # 2. Run test try: project = Project() value = project.get_parameter("IDoNoTExist") except Exception as e: pytest.fail("No exception expected, but thrown: {}".format(str(e))) # 3. Verify final expectations assert project is not None assert value is None
def test_if_get_output_directory_then_returned(self): # 1. Set up initial test dat project = None value = None # 2. Run test try: project = Project() value = project.get_output_directory() except Exception as e: pytest.fail("No exception expected, but thrown: {}".format(str(e))) # 3. Verify final expectations assert project is not None assert value is not None
def test_if_get_existing_inputfile_then_returned(self): # 1. Set up initial test dat project = None value = None # 2. Run test try: project = Project() value = project.get_input_file("CrossSectionLocationFile") except Exception as e: pytest.fail("No exception expected, but thrown: {}".format(str(e))) # 3. Verify final expectations assert project is not None assert value is not None
def cli(**kwargs): project = None if kwargs.get("f"): project = Project(kwargs.get("f")) if kwargs.get("n"): # Create empty project based on inifile inifile = IniFile().print_configuration() new_name = kwargs.get("n") ini_path = f"{new_name}.ini" # inifile = re.sub('(NoName)', inifile, new_name) with open(ini_path, "w") as f: f.write(inifile) click.echo(f"{ini_path} written to file") if kwargs.get("r"): click.echo(project.run()) else: with click.Context(cli) as ctx: click.echo(ctx.get_help())
def test_run_without_input_no_exception_is_raised(self): project = Project() project.run()
def test_when_no_file_path_then_no_exception_is_risen(self): # 1. Set up initial test dat project = Project() assert project is not None