Esempio n. 1
0
def test_main(datadir):
    """Test the main function used by the command line client"""
    ofmvol2csv.ofmvol2csv_main(
        "ofm_example.vol", "volfiles.csv", includefileorigin=True
    )

    output = pd.read_csv("volfiles.csv")
    assert isinstance(output, pd.DataFrame)
    # pylint: disable=no-member
    assert not output.empty
    assert len(output) == 4379
    assert set(output.columns) == {
        "WELL",
        "DATE",
        "OIL",
        "GAS",
        "WATER",
        "GINJ",
        "DAYS",
        "OFMVOLFILE",
    }
    assert set(output["WELL"].unique()) == {
        "WELL_A",
        "WELL_B",
        "WELL_C",
        "WELL_D",
        "WELL_E",
    }
    assert round(output["OIL"].sum(), 0) == 3243320
    assert round(output["GAS"].sum(), 0) == 545934037
    assert round(output["WATER"].sum(), 0) == 447465
    assert round(output["GINJ"].sum(), 0) == 92701411
    assert int(output["DAYS"].mean()) == 24
Esempio n. 2
0
def test_cmdline_globbing(datadir):
    ofmvol2csv.ofmvol2csv_main("file*.vol", "volfiles.csv", includefileorigin=True)
    output = pd.read_csv("volfiles.csv")
    assert isinstance(output, pd.DataFrame)
    assert not output.empty
    assert set(output["OFMVOLFILE"]) == {"fileA.vol", "fileB.vol", "fileC.vol"}
    assert len(output) == 17
    assert output["WELL"].is_monotonic

    ofmvol2csv.ofmvol2csv_main(
        ["fileA.vol", "fileB.vol", "fileC.vol"],
        "volfiles-alt.csv",
        includefileorigin=True,
    )
    output_alt = pd.read_csv("volfiles-alt.csv")
    pd.testing.assert_frame_equal(output, output_alt)
Esempio n. 3
0
def test_roundtrip(datadir):
    """Test that ofmvol2csv and csv2ofmvol can work together as inverses
    of each other."""
    ofmvol2csv.ofmvol2csv_main(
        ["ofm_example.vol"], "volfiles.csv", includefileorigin=False
    )

    first_frame = pd.read_csv("volfiles.csv")

    sys.argv = ["csv2ofmvol", "volfiles.csv", "--output", "backagain.vol"]
    csv2ofmvol.main()

    ofmvol2csv.ofmvol2csv_main(["backagain.vol"], "take2.csv", includefileorigin=False)
    second_frame = pd.read_csv("take2.csv")

    print(first_frame.head())
    print(second_frame.head())

    pd.testing.assert_frame_equal(first_frame, second_frame)
Esempio n. 4
0
def test_no_files(tmp_path):
    """Test what happens when input does not exist"""
    os.chdir(tmp_path)
    ofmvol2csv.ofmvol2csv_main("bogus*.vol", "volfiles.csv")
    assert not Path("volfiles.csv").exists()
Esempio n. 5
0
def test_no_files(tmpdir):
    tmpdir.chdir()
    ofmvol2csv.ofmvol2csv_main("bogus*.vol", "volfiles.csv")
    assert not Path("volfiles.csv").exists()