def test_tap_size(self): with pytest.warns(W03): vosi.parse_tables(get_pkg_data_filename( "data/tables/sizenegative.xml")) with pytest.raises(W03): vosi.parse_tables(get_pkg_data_filename( "data/tables/sizenegative.xml"), pedantic=True)
def test_multiple_targettables(self): with pytest.warns(W12): vosi.parse_tables(get_pkg_data_filename( "data/tables/multiple_targettables.xml")) with pytest.raises(W12): vosi.parse_tables(get_pkg_data_filename( "data/tables/multiple_targettables.xml"), pedantic=True)
def test_wrong_flag(self): with pytest.warns(W04): vosi.parse_tables(get_pkg_data_filename( "data/tables/wrong_flag.xml")) with pytest.raises(W04): vosi.parse_tables(get_pkg_data_filename( "data/tables/wrong_flag.xml"), pedantic=True)
def test_no_schemas(self): with pytest.warns(W14): vosi.parse_tables( get_pkg_data_filename("data/tables/no_schemas.xml")) with pytest.raises(W14): vosi.parse_tables( get_pkg_data_filename("data/tables/no_schemas.xml"), pedantic=True)
def test_multiple_schema_descriptions(self): with pytest.warns(W06): vosi.parse_tables(get_pkg_data_filename( "data/tables/multiple_schema_descriptions.xml")) with pytest.raises(W06): vosi.parse_tables( get_pkg_data_filename( "data/tables/multiple_schema_descriptions.xml"), pedantic=True)
def test_multiple_foreignkey_utypes(self): with pytest.warns(W09): vosi.parse_tables(get_pkg_data_filename( "data/tables/multiple_foreignkey_utypes.xml")) with pytest.raises(W09): vosi.parse_tables( get_pkg_data_filename( "data/tables/multiple_foreignkey_utypes.xml"), pedantic=True)
def test_datatypes_tap(self): tablesfile = vosi.parse_tables( get_pkg_data_filename("data/tables/datatypes_tap.xml")) tap, taptype = tuple(tablesfile.iter_tables()) self._test_datatypes_tap(tap.columns) self._test_datatypes_tap(taptype.columns)
def test_all(self): tablesfile = vosi.parse_tables( get_pkg_data_filename("data/tables.xml")) table = next(tablesfile.iter_tables()) assert table.name == "test.all" assert table.title == "Test table" assert table.description == "All test data in one table" assert table.utype == "utype" col = table.columns[0] fkc = table.foreignkeys[0] assert col.name == "id" assert col.description == "Primary key" assert col.unit == "unit" assert col.ucd == "meta.id;meta.main" assert col.utype == "utype" assert type(col.datatype) == vs.TAPType assert col.datatype.arraysize == "*" assert col.datatype.delim == ';' assert col.datatype.size == "42" assert col.datatype.content == "VARCHAR" assert "indexed" in col.flags assert "primary" in col.flags assert fkc.targettable == "test.foreigntable" assert fkc.fkcolumns[0].fromcolumn == "testkey" assert fkc.fkcolumns[0].targetcolumn == "testkey" assert fkc.description == "Test foreigner" assert fkc.utype == "utype"
def test_all(self): tablesfile = vosi.parse_tables( get_pkg_data_filename("data/tables.xml")) table = next(tablesfile.iter_tables()) assert table.name == "test.all" assert table.title == "Test table" assert table.description == "All test data in one table" assert table.utype == "utype" col = table.columns[0] fkc = table.foreignkeys[0] assert col.name == "id" assert col.description == "Primary key" assert col.unit == "unit" assert col.ucd == "meta.id;meta.main" assert col.utype == "utype" assert type(col.datatype) == vs.TAPType assert str(col.datatype) == "<DataType arraysize=*>VARCHAR</DataType>" assert col.datatype.arraysize == "*" assert col.datatype.delim == ";" assert col.datatype.size == "42" assert col.datatype.content == "VARCHAR" assert "indexed" in col.flags assert "primary" in col.flags assert fkc.targettable == "test.foreigntable" assert fkc.fkcolumns[0].fromcolumn == "testkey" assert fkc.fkcolumns[0].targetcolumn == "testkey" assert fkc.description == "Test foreigner" assert fkc.utype == "utype"
def test_datatypes_votable(self): tablesfile = vosi.parse_tables( get_pkg_data_filename("data/tables/datatypes_votable.xml")) votable, votabletype = tuple(tablesfile.iter_tables()) self._test_datatypes_votable(votable.columns) self._test_datatypes_votable(votabletype.columns)
def test_no_table_description(self): """Test handling of describing tables with no description """ tableset = vosi.parse_tables( get_pkg_data_filename( "data/tables/no_table_description.xml")) nodesc_table = tableset.get_first_table() assert nodesc_table.description is None with io.StringIO() as buf, contextlib.redirect_stdout(buf): nodesc_table.describe() output = buf.getvalue() assert 'No description' in output
def test_single_table_description(self): """Test describing a table with a single description """ tableset = vosi.parse_tables( get_pkg_data_filename( "data/tables/single_table_description.xml")) onedesc_table = tableset.get_first_table() describe_string = 'A test table with a single description' assert describe_string in onedesc_table.description with io.StringIO() as buf, contextlib.redirect_stdout(buf): onedesc_table.describe() output = buf.getvalue() assert describe_string in output
def test_wrong_datatypes_votable(self): with pytest.warns(W02): vosi.parse_tables(get_pkg_data_filename( "data/tables/wrong_datatypes_votable.xml"))
def test_wrong_arraysize(self): with pytest.raises(E01): vosi.parse_tables( get_pkg_data_filename( "data/tables/wrong_arraysize.xml"))
def test_no_table_name(self): with pytest.raises(E06): vosi.parse_tables( get_pkg_data_filename("data/tables/no_table_name.xml"))
def test_missing_targetcolumn(self): with pytest.raises(E03): vosi.parse_tables(get_pkg_data_filename( "data/tables/no_targetcolumn.xml"))