Ejemplo n.º 1
0
def test_table_ods_sheet_by_index_not_existent():
    dialect = OdsDialect(sheet=3)
    table = Table("data/table.ods", dialect=dialect)
    with pytest.raises(exceptions.FrictionlessException) as excinfo:
        table.open()
    error = excinfo.value.error
    assert error.code == "format-error"
    assert error.note == 'OpenOffice document "data/table.ods" does not have a sheet "3"'
Ejemplo n.º 2
0
def test_ods_parser_sheet_by_name_not_existent():
    dialect = OdsDialect(sheet="bad")
    table = Resource("data/table.ods", dialect=dialect)
    with pytest.raises(FrictionlessException) as excinfo:
        table.open()
    error = excinfo.value.error
    assert error.code == "format-error"
    assert (error.note ==
            'OpenOffice document "data/table.ods" does not have a sheet "bad"')
Ejemplo n.º 3
0
def test_ods_parser_sheet_by_name():
    dialect = OdsDialect(sheet="Лист1")
    with Resource("data/table.ods", dialect=dialect) as resource:
        assert resource.header == ["id", "name"]
        assert resource.read_rows() == [
            {
                "id": 1,
                "name": "english"
            },
            {
                "id": 2,
                "name": "中国人"
            },
        ]
Ejemplo n.º 4
0
def test_table_ods_sheet_by_name():
    dialect = OdsDialect(sheet="Лист1")
    with Table("data/table.ods", dialect=dialect) as table:
        assert table.header == ["id", "name"]
        assert table.read_data() == [[1, "english"], [2, "中国人"]]
Ejemplo n.º 5
0
def test_ods_parser_sheet_by_index():
    dialect = OdsDialect(sheet=1)
    with Table("data/table.ods", dialect=dialect) as table:
        assert table.header == ["id", "name"]
        assert table.read_data() == [[1, "english"], [2, "中国人"]]