示例#1
0
def test_rsync_profile4(datatree):
    """Testing vs filter profile 4."""
    os.chdir(datatree)
    target = "mytest4"
    source = "20.1.1"
    runner = fcr.CopyFMU()
    runner.do_parse_args("")
    runner.profile = 4
    runner.source = source
    runner.construct_target(target)
    runner.define_filterpattern()
    print(runner.filter)
    runner.do_rsyncing()

    assert (datatree / target / "rms" / "input" / "faults" / "f1.dat").exists()

    # profile 4: rms/output folders will be empty as in option 3 and
    # hence removed according to option 4
    assert not (datatree / target / "rms" / "output").exists()
    assert not (datatree / target / "rms" / "output" / "anyfolder").exists()
    assert not (
        datatree / target / "rms" / "output" / "anyfolder" / "some_out.dat"
    ).exists()

    assert not (datatree / target / "rms" / "input" / "faults" / "x.dat").exists()
    assert not (datatree / target / "backup").is_dir()
示例#2
0
def test_rsync_profile3(datatree):
    """Testing vs filter profile 3."""
    os.chdir(datatree)
    target = "mytest3"
    source = "20.1.1"
    runner = fcr.CopyFMU()
    runner.do_parse_args("")
    runner.profile = 3
    runner.source = source
    runner.construct_target(target)
    runner.define_filterpattern()
    print(runner.filter)
    runner.do_rsyncing()

    assert (datatree / target / "rms" / "input" / "faults" / "f1.dat").exists()

    # profile 3: rms/output folders shall be kept but not files
    assert (datatree / target / "rms" / "output").exists()
    assert (datatree / target / "rms" / "output" / "anyfolder").exists()
    assert not (
        datatree / target / "rms" / "output" / "anyfolder" / "some_out.dat"
    ).exists()

    assert not (datatree / target / "rms" / "input" / "faults" / "x.dat").exists()
    assert not (datatree / target / "backup").is_dir()
示例#3
0
def test_construct_target_shall_fail(datatree):
    """Test the construct target routine with non-existing folder."""
    os.chdir(datatree)

    runner = fcr.CopyFMU()
    runner.do_parse_args("")

    runner.source = "nada"
    with pytest.raises(ValueError) as verr:
        runner.construct_default_target()

    assert "Input folder does not exist" in str(verr)
示例#4
0
def test_rsync_profile1(datatree):
    """Testing vs filter profile 1."""
    os.chdir(datatree)
    target = "mytest1"
    source = "20.1.1"
    runner = fcr.CopyFMU()
    runner.do_parse_args("")
    runner.profile = 1
    runner.source = source
    runner.construct_target(target)
    runner.define_filterpattern()
    runner.do_rsyncing()

    assert (datatree / target / "rms" / "input" / "faults" / "f1.dat").exists()
    assert not (datatree / target / "rms" / "input" / "faults" / "x.dat").exists()
    assert (datatree / target / "backup").is_dir()
示例#5
0
def test_construct_target(datatree):
    """Test the construct target routine."""

    os.chdir(datatree)
    today = time.strftime("%Y%m%d")
    user = getpass.getuser()
    expected = "some_20.1.1"

    runner = fcr.CopyFMU()
    runner.do_parse_args("")
    runner.verbosity = True
    runner.source = "20.1.1"
    runner.construct_target("some_20.1.1")

    assert str(runner.target) == str(datatree / expected)

    expected = "users/" + user + "/20.1.1/20.1.1_" + today
    runner.construct_default_target()
    assert expected in str(runner.default_target)