예제 #1
0
def test_property_table_json():
    tbl = PropertyTable(data=dummy_data, metadata={"baz": "2"})
    s = tbl.dumps()
    parsed = json.loads(s)
    assert parsed["data"] == tbl.data.as_list()
    tmp_dir = scratch_path / "property_table_json"
    tmp_dir.mkdir()
    tbl.dump((tmp_dir / "tbl.json").open("w"))
    parsed = json.load((tmp_dir / "tbl.json").open())
    assert parsed["data"] == tbl.data.as_list()
예제 #2
0
def test_property_table_json():
    tbl = PropertyTable(data=dummy_data, metadata={"baz": "2"})
    s = tbl.dumps()
    parsed = json.loads(s)
    assert parsed["data"] == tbl.data.as_list()
    with TempDir() as d:
        fp = open(os.path.join(d, "tbl.json"), "w")
        tbl.dump(fp)
        fp.close()
        fp = open(os.path.join(d, "tbl.json"), "r")
        parsed = json.load(fp)
    assert parsed["data"] == tbl.data.as_list()
예제 #3
0
def test_property_table_json():
    tbl = PropertyTable(data=dummy_data, metadata={'baz': '2'})
    s = tbl.dumps()
    parsed = json.loads(s)
    assert parsed['data'] == tbl.data.as_list()
    with TempDir() as d:
        fp = open(os.path.join(d, 'tbl.json'), 'w')
        tbl.dump(fp)
        fp.close()
        fp = open(os.path.join(d, 'tbl.json'), 'r')
        parsed = json.load(fp)
    assert parsed['data'] == tbl.data.as_list()
예제 #4
0
def test_property_table_from_json():
    tmp_dir = scratch_path / "property_table_from_json"
    tmp_dir.mkdir()
    prop_path = tmp_dir / "prop.json"
    for gj in good_table_json:
        json.dump(gj, prop_path.open("w"))
        tbl = PropertyTable.load(prop_path.open())
        assert tbl.data.num_columns == 2
예제 #5
0
def test_property_table_from_json():
    with TempDir() as d:
        filename = os.path.join(d, "prop.json")
        for gj in good_table_json:
            fp = open(filename, "w")
            json.dump(gj, fp)
            fp.close()
            fp = open(filename, "r")
            tbl = PropertyTable.load(fp)
            assert tbl.data.num_columns == 2
        os.unlink(filename)
예제 #6
0
def test_property_table_objinit():
    d = PropertyData(dummy_data)
    m = PropertyMetadata({"bar": "y"})
    tbl = PropertyTable(data=d, metadata=m)
    assert tbl.data.as_list()[0]["units"] == "none"
    assert tbl.metadata[0].as_dict()["bar"] == "y"
예제 #7
0
def test_property_table():
    tbl = PropertyTable(data=dummy_data, metadata=[])
    assert tbl.data is not None
    assert tbl.metadata is not None
예제 #8
0
def test_property_table_empty():
    with pytest.raises(ValueError):
        PropertyTable(data=[], metadata=[])
예제 #9
0
def test_property_table_objinit():
    d = PropertyData(dummy_data)
    m = PropertyMetadata({'bar': 'y'})
    tbl = PropertyTable(data=d, metadata=m)
    assert tbl.data.as_list()[0]['units'] == 'none'
    assert tbl.metadata[0].as_dict()['bar'] == 'y'