Ejemplo n.º 1
0
def test_property_data_column_nonexistent():
    csv_input = good_data_csv[0]
    obj = PropertyData.from_csv(StringIO(csv_input), 1)
    try:
        obj.get_column("this is not a column")
        assert False, "Expected failure for bogus column"
    except KeyError:
        pass
Ejemplo n.º 2
0
def test_property_data_column_type():
    csv_input = good_data_csv[0]
    obj = PropertyData.from_csv(StringIO(csv_input), 1)
    csv_header = csv_input.split("\n")[0].split(",")
    for i, col in enumerate((csv_header[1], csv_header[3])):
        units_pos = col.find("(")
        if units_pos >= 0:
            col = col[:units_pos].strip()
        obj.get_column(col)
        index = obj.get_column_index(col)
        if i == 0:
            assert obj.is_state_column(index)
        else:
            assert obj.is_property_column(index)
Ejemplo n.º 3
0
def pd():
    # create main propertydata obj
    return PropData.from_csv(StringIO(test_data["main"]), 1)
Ejemplo n.º 4
0
def test_property_data_bad():
    inputs = map(StringIO, bad_data_csv)
    for inpfile in inputs:
        with pytest.raises(Exception):
            PropertyData.from_csv(inpfile, 0)
Ejemplo n.º 5
0
def test_property_data_good():
    inputs = map(StringIO, good_data_csv)
    states, total = [1], [2]
    for inpfile, state_col, ncol in zip(inputs, states, total):
        obj = PropertyData.from_csv(inpfile, state_col)
        assert obj.num_columns == ncol