コード例 #1
0
ファイル: test_fixtures.py プロジェクト: telia-oss/birgitta
def test_get_val_0():
    """This is necessary to ensure that row_conf field val 0 is not
    treated as None when deriving the fixture val."""
    catalog = Catalog()
    catalog.add_field('dummyval', description='Dummy val', example=39)
    schema = Schema([['dummyval', 'bigint']], catalog)
    row_conf = RowConf()
    row_conf.set_field('dummyval', 0)
    dummy_val = fixtures.get_val(schema, row_conf, 'dummyval')
    # Must be 0, not 39
    assert dummy_val == 0
コード例 #2
0
def test_write_without_set_schema():
    dataiku_source = DataikuSource()
    dataset_name = "fixtures"
    s3_dir = "s3://birgittatestbucket/sourcetests"
    fixtures_mock = MagicMock()
    catalog = Catalog()
    catalog.add_field('fooint', description='Foo int', example=39)
    schema = Schema([['fooint', 'bigint']], catalog)
    dataframe.write(fixtures_mock,
                    dataset_name,
                    prefix=s3_dir,
                    schema=schema,
                    skip_cast=True,
                    set_schema=False,
                    dataframe_source=dataiku_source)
    dapi_dataset_mock.set_schema.assert_not_called()
コード例 #3
0
def test_write():
    # dapi_dataset_mock = mock.MagicMock()
    # project_obj_mock.get_dataset.return_value = dapi_dataset_mock
    dataiku_source = DataikuSource()
    dataset_name = "fixtures"
    s3_dir = "s3://birgittatestbucket/sourcetests"
    fixtures_mock = MagicMock()
    catalog = Catalog()
    catalog.add_field('fooint', description='Foo int', example=39)
    schema = Schema([['fooint', 'bigint']], catalog)
    dataframe.write(fixtures_mock,
                    dataset_name,
                    prefix=s3_dir,
                    schema=schema,
                    skip_cast=True,
                    dataframe_source=dataiku_source)
    dataiku_schema = dkuschema.to_dataiku(schema)
    dapi_dataset_mock.set_schema.assert_called_once_with(dataiku_schema)
コード例 #4
0
def test_to_dataiku():
    """This is necessary to ensure that row_conf field val 0 is not
    treated as None when deriving the fixture val."""
    catalog = Catalog()
    catalog.add_field('foobool', description='Foo bool', example=True)
    catalog.add_field('foobigint', description='Foo bigint', example=3999999)
    catalog.add_field('fooint', description='Foo int', example=39)
    catalog.add_field('foolong', description='Foo long', example=399)
    catalog.add_field('foofloat', description='Foo float', example=22.2)
    catalog.add_field('foodouble', description='Foo double', example=22.2)
    catalog.add_field('foostring', description='Foo string', example="foo")
    catalog.add_field('footimestamp',
                      description='Foo timestamp',
                      example=datetime.datetime.now())
    catalog.add_field('foodate',
                      description='Foo date',
                      example=datetime.date.today())
    schema_list = [['foobool', 'bool'], ['foobigint', 'bigint'],
                   ['fooint', 'int'], ['foolong', 'long'],
                   ['foofloat', 'float'], ['foodouble', 'double'],
                   ['foostring', 'string'], ['footimestamp', 'timestamp'],
                   ['foodate', 'date']]
    schema = Schema(schema_list, catalog)
    expected_schema = {
        'userModified':
        True,
        'columns': [
            {
                'name': 'foobool',
                'type': 'boolean',
                'comment': 'Foo bool',
                'meaning': 'Boolean'
            },
            {
                'name': 'foobigint',
                'type': 'bigint',
                'comment': 'Foo bigint',
                'meaning': 'Integer'
            },
            {
                'name': 'fooint',
                'type': 'int',
                'comment': 'Foo int',
                'meaning': 'Integer'
            },
            {
                'name': 'foolong',
                'type': 'bigint',
                'comment': 'Foo long',
                'meaning': 'Integer'
            },
            {
                'name': 'foofloat',
                'type': 'float',
                'comment': 'Foo float',
                'meaning': 'Decimal'
            },
            {
                'name': 'foodouble',
                'type': 'double',
                'comment': 'Foo double',
                'meaning': 'Decimal'
            },
            {
                'name': 'foostring',
                'type': 'string',
                'comment': 'Foo string',
                'meaning': 'Text'
            },
            {
                'name': 'footimestamp',
                'type': 'date',
                'comment': 'Foo timestamp',
                'meaning': 'Date'
            },
            {
                'name': 'foodate',
                'type': 'date',
                'comment': 'Foo date',
                'meaning': 'Date'
            },
        ]
    }
    dataiku_schema = dkuschema.to_dataiku(schema)
    assert dataiku_schema == expected_schema
コード例 #5
0
ファイル: schema.py プロジェクト: telia-oss/birgitta
from birgitta.schema.fixtures import ExampleVal
from birgitta.schema.fixtures import values as v
from birgitta.schema.schema import Schema

from .....shared.schema.catalog.tribune import catalog

FIELDS = [["sequence_no", "bigint"], ["customer_id", "bigint"],
          ["phone", "string"], ["group_account_id", "bigint"],
          ["product_code", "string"], ["product", "string"],
          ["segment", "string"], ["product_payment_type", "string"],
          ["product_name", "string"], ["brand_name", "string"],
          ["start_date", "date"], ["end_date", "date",
                                   ExampleVal(v.today())],
          ["shop_code", "string"], ["product_category", "string"]]

schema = Schema(FIELDS, catalog)
コード例 #6
0
ファイル: test_schema.py プロジェクト: telia-oss/birgitta
def wrong_nulls_schema():
    catalog = Catalog()
    arr_schema = [['letter', 'string', Nullable(False)],
                  ['number', 'bigint', Nullable(False)]]
    return Schema(arr_schema, catalog)
コード例 #7
0
ファイル: test_schema.py プロジェクト: telia-oss/birgitta
def one_field_schema():
    catalog = Catalog()
    arr_schema = [['letter', 'string']]
    return Schema(arr_schema, catalog)
コード例 #8
0
ファイル: test_schema.py プロジェクト: telia-oss/birgitta
def wrong_fields_schema():
    catalog = Catalog()
    arr_schema = [['notletter', 'string'], ['notnumber', 'bigint']]
    return Schema(arr_schema, catalog)
コード例 #9
0
ファイル: test_schema.py プロジェクト: telia-oss/birgitta
def wrong_types_schema():
    catalog = Catalog()
    arr_schema = [['letter', 'float'], ['number', 'timestamp']]
    return Schema(arr_schema, catalog)
コード例 #10
0
ファイル: test_schema.py プロジェクト: telia-oss/birgitta
def default_schema():
    catalog = Catalog()
    arr_schema = [['letter', 'string'], ['number', 'bigint']]
    return Schema(arr_schema, catalog)
コード例 #11
0
from birgitta.schema.schema import Schema

from .....shared.schema.catalog.tribune_chronicle import catalog

fields = [
    ['customer_id', 'bigint'],
    ['phone', 'string'],
    ['chronicle_account_id', 'bigint'],
    ['group_account_id', 'bigint'],
    ['start_date', 'date'],
    ['end_date', 'date'],
    ['priceplan_code', 'string'],
    ['current_flag', 'bigint'],
    ['client_status_code', 'bigint']
]

schema = Schema(fields, catalog)