예제 #1
0
 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)))
예제 #2
0
    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
예제 #3
0
    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
예제 #4
0
    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
예제 #5
0
    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
예제 #6
0
    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
예제 #7
0
    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
예제 #8
0
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())
예제 #9
0
 def test_run_without_input_no_exception_is_raised(self):
     project = Project()
     project.run()
예제 #10
0
 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