def test_schema():
    schema = Schema(name='My Table', parent="syn1000001")

    assert not schema.has_columns()

    schema.addColumn(Column(id='1', name='Name', columnType='STRING'))

    assert schema.has_columns()
    assert schema.properties.columnIds == ['1']

    schema.removeColumn('1')
    assert not schema.has_columns()
    assert schema.properties.columnIds == []

    schema = Schema(name='Another Table', parent="syn1000001")

    schema.addColumns([
        Column(name='Name', columnType='STRING'),
        Column(name='Born', columnType='INTEGER'),
        Column(name='Hipness', columnType='DOUBLE'),
        Column(name='Living', columnType='BOOLEAN')])
    assert schema.has_columns()
    assert len(schema.columns_to_store) == 4
    assert Column(name='Name', columnType='STRING') in schema.columns_to_store
    assert Column(name='Born', columnType='INTEGER') in schema.columns_to_store
    assert Column(name='Hipness', columnType='DOUBLE') in schema.columns_to_store
    assert Column(name='Living', columnType='BOOLEAN') in schema.columns_to_store

    schema.removeColumn(Column(name='Living', columnType='BOOLEAN'))
    assert schema.has_columns()
    assert len(schema.columns_to_store) == 3
    assert Column(name='Living', columnType='BOOLEAN') not in schema.columns_to_store
    assert Column(name='Hipness', columnType='DOUBLE') in schema.columns_to_store
def test_schema():
    schema = Schema(name='My Table', parent="syn1000001")

    assert_false(schema.has_columns())

    schema.addColumn(Column(id='1', name='Name', columnType='STRING'))

    assert_true(schema.has_columns())
    assert_equals(schema.properties.columnIds, ['1'])

    schema.removeColumn('1')
    assert_false(schema.has_columns())
    assert_equals(schema.properties.columnIds, [])

    schema = Schema(name='Another Table', parent="syn1000001")

    schema.addColumns([
        Column(name='Name', columnType='STRING'),
        Column(name='Born', columnType='INTEGER'),
        Column(name='Hipness', columnType='DOUBLE'),
        Column(name='Living', columnType='BOOLEAN')])
    assert_true(schema.has_columns())
    assert_equals(len(schema.columns_to_store), 4)
    assert_in(Column(name='Name', columnType='STRING'), schema.columns_to_store)
    assert_in(Column(name='Born', columnType='INTEGER'), schema.columns_to_store)
    assert_in(Column(name='Hipness', columnType='DOUBLE'), schema.columns_to_store)
    assert_in(Column(name='Living', columnType='BOOLEAN'), schema.columns_to_store)

    schema.removeColumn(Column(name='Living', columnType='BOOLEAN'))
    assert_true(schema.has_columns())
    assert_equals(len(schema.columns_to_store), 3)
    assert_not_in(Column(name='Living', columnType='BOOLEAN'), schema.columns_to_store)
    assert_in(Column(name='Hipness', columnType='DOUBLE'), schema.columns_to_store)
def test_schema():
    schema = Schema(name='My Table', parent="syn1000001")

    assert not schema.has_columns()

    schema.addColumn(Column(id='1', name='Name', columnType='STRING'))

    assert schema.has_columns()
    assert schema.properties.columnIds == ['1']

    schema.removeColumn('1')
    assert not schema.has_columns()
    assert schema.properties.columnIds == []

    schema = Schema(name='Another Table', parent="syn1000001")

    schema.addColumns([
        Column(name='Name', columnType='STRING'),
        Column(name='Born', columnType='INTEGER'),
        Column(name='Hipness', columnType='DOUBLE'),
        Column(name='Living', columnType='BOOLEAN')])
    assert schema.has_columns()
    assert len(schema.columns_to_store) == 4
    assert Column(name='Name', columnType='STRING') in schema.columns_to_store
    assert Column(name='Born', columnType='INTEGER') in schema.columns_to_store
    assert Column(name='Hipness', columnType='DOUBLE') in schema.columns_to_store
    assert Column(name='Living', columnType='BOOLEAN') in schema.columns_to_store

    schema.removeColumn(Column(name='Living', columnType='BOOLEAN'))
    assert schema.has_columns()
    assert len(schema.columns_to_store) == 3
    assert Column(name='Living', columnType='BOOLEAN') not in schema.columns_to_store
    assert Column(name='Hipness', columnType='DOUBLE') in schema.columns_to_store
示例#4
0
def test_schema():
    schema = Schema(name='My Table', parent="syn1000001")

    assert_false(schema.has_columns())

    schema.addColumn(Column(id='1', name='Name', columnType='STRING'))

    assert_true(schema.has_columns())
    assert_equals(schema.properties.columnIds, ['1'])

    schema.removeColumn('1')
    assert_false(schema.has_columns())
    assert_equals(schema.properties.columnIds, [])

    schema = Schema(name='Another Table', parent="syn1000001")

    schema.addColumns([
        Column(name='Name', columnType='STRING'),
        Column(name='Born', columnType='INTEGER'),
        Column(name='Hipness', columnType='DOUBLE'),
        Column(name='Living', columnType='BOOLEAN')
    ])
    assert_true(schema.has_columns())
    assert_equals(len(schema.columns_to_store), 4)
    assert_in(Column(name='Name', columnType='STRING'),
              schema.columns_to_store)
    assert_in(Column(name='Born', columnType='INTEGER'),
              schema.columns_to_store)
    assert_in(Column(name='Hipness', columnType='DOUBLE'),
              schema.columns_to_store)
    assert_in(Column(name='Living', columnType='BOOLEAN'),
              schema.columns_to_store)

    schema.removeColumn(Column(name='Living', columnType='BOOLEAN'))
    assert_true(schema.has_columns())
    assert_equals(len(schema.columns_to_store), 3)
    assert_not_in(Column(name='Living', columnType='BOOLEAN'),
                  schema.columns_to_store)
    assert_in(Column(name='Hipness', columnType='DOUBLE'),
              schema.columns_to_store)