Пример #1
0
def test_filter():
    tpl = Tpl("FC1_rev01.tpl")
    PTs = tpl.filter_data('PT')
    assert 'PT' in PTs[3]
    assert 'POSITION' in PTs[3]
    assert 'TIEIN' in PTs[3]
    tpl.trends
    assert 'VOLGB' in tpl.trends[1]
Пример #2
0
def test_filter():
    tpl = Tpl(TEST_FLD+"/FC1_rev01.tpl")
    PTs = tpl.filter_trends('PT')
    assert 'PT' in PTs[3]
    assert 'POSITION' in PTs[3]
    assert 'TIEIN' in PTs[3]
    tpl.trends
    assert 'VOLGB' in tpl.trends[1]
Пример #3
0
def test_multiple_extraction():
    tpl = Tpl(TEST_FLD+"/FC1_rev01.tpl")
    tpl.extract(3, 4, 5)
    assert tpl.data[3][0] == 9.973410e6
    assert 'Pressure' in tpl.label[3]
    assert tpl.data[4][0] == 1.291370e1
    assert 'temperature' in tpl.label[4]
    assert tpl.data[5][0] == 1.00000000
    assert 'Holdup' in tpl.label[5]
Пример #4
0
def test_to_excel():
    tpl = Tpl("FC1_rev01.tpl")
    tpl.to_excel()
    assert "FC1_rev01_tpl.xlsx" in os.listdir()
    xl = xlrd.open_workbook("FC1_rev01_tpl.xlsx")
    sh = xl.sheet_by_index(0)
    assert sh.cell_value(3, 4) == 9.973300e+06
    os.remove("FC1_rev01_tpl.xlsx")
    tpl.to_excel("/tmp")
    assert "FC1_rev01_tpl.xlsx" in os.listdir("/tmp")
    os.remove("/tmp/FC1_rev01_tpl.xlsx")
Пример #5
0
def test_to_excel():
    tpl = Tpl(TEST_FLD+"/FC1_rev01.tpl")
    tpl.to_excel()
    assert "FC1_rev01_tpl.xlsx" in os.listdir(TEST_FLD)
    xl = xlrd.open_workbook(TEST_FLD+"/FC1_rev01_tpl.xlsx")
    sh = xl.sheet_by_index(0)
    assert sh.cell_value(3, 4) == 9.973300e+06
    os.remove(TEST_FLD+"/FC1_rev01_tpl.xlsx")
    temp_folder = tempfile.gettempdir()
    tpl.to_excel(temp_folder)
    assert "FC1_rev01_tpl.xlsx" in os.listdir(temp_folder)
    os.remove(temp_folder+"/FC1_rev01_tpl.xlsx")
Пример #6
0
def test_not_a_tpl():
    with pytest.raises(ValueError) as exeinfo:
        tpl = Tpl("FC1_rev01.ppl")
        assert exinfo.value.message == "not a tpl file"
Пример #7
0
def test_extraction():
    tpl = Tpl("FC1_rev01.tpl")
    tpl.extract(3)
    assert tpl.data[3][0] == 9.973410e6
    assert 'Pressure' in tpl.label[3]
Пример #8
0
def test_attributes():
    tpl = Tpl("FC1_rev01.tpl")
    assert tpl._attibutes['CATALOG'] == 331
    assert tpl._attibutes['data_idx'] == 421
    assert 'VOLGB' in tpl.trends[1]
Пример #9
0
def test_init():
    tpl = Tpl("FC1_rev01.tpl")
    assert tpl.fname == "FC1_rev01.tpl"
Пример #10
0
def test_view_trends():
    tpl = Tpl(TEST_FLD+"/FC1_rev01.tpl")
    df = tpl.view_trends()
    df = tpl.view_trends('HOL')
    assert df['Index'][4] == 36
    assert df['Position'][4] == 'POSITION - VENT_LINE'
Пример #11
0
def test_extraction_preprocessor():
    tpl = Tpl(TEST_FLD+"/2016_1_Legacy.tpl")
    tpl.extract(4)
    assert tpl.data[4][0] == 487.87419999999997
    assert 'OILC' in tpl.label[4]
Пример #12
0
def test_init():
    tpl = Tpl(TEST_FLD+"FC1_rev01.tpl")
    assert tpl.fname == "FC1_rev01.tpl"
    assert tpl.path == TEST_FLD[:-1]
Пример #13
0
def test_init_same_folder():
    tpl = Tpl("tpl_file.tpl")
    assert tpl.path == ''
    assert tpl.fname == "tpl_file.tpl"
Пример #14
0
def test_init():
    tpl = Tpl("FC1_rev01.tpl")
    assert tpl.fname == "FC1_rev01.tpl"
    assert int(tpl.time[1]) == 60