def test_create_column_metadata(self):
        cols = [{'pos': 1, 'name': 'col1', 'type': 'int2', 'nullable': 'NO'},
                {'pos': 2, 'name': 'col2', 'type': 'float8',
                 'nullable': 'YES'},
                {'pos': 3, 'name': 'col3', 'type': 'timestamptz',
                 'nullable': 'NO'}]
        db_name = 'test-db'
        table_name = 'test_table'
        key_properties = ['col1']
        is_view = False
        expected_mdata = metadata.new()
        metadata.write(expected_mdata, (), 'selected-by-default', False)
        metadata.write(expected_mdata, (), 'valid-replication-keys', ['col3'])
        metadata.write(expected_mdata, (),
                       'table-key-properties', key_properties)
        metadata.write(expected_mdata, (), 'is-view', is_view)
        metadata.write(expected_mdata, (), 'schema-name', table_name)
        metadata.write(expected_mdata, (), 'database-name', db_name)
        for col in cols:
            schema = tap_redshift.schema_for_column(col)
            metadata.write(expected_mdata, (
                'properties', col['name']), 'selected-by-default', True)
            metadata.write(expected_mdata, (
                'properties', col['name']), 'sql-datatype', col['type'])
            metadata.write(expected_mdata, (
                'properties', col['name']), 'inclusion', schema.inclusion)

        actual_mdata = tap_redshift.create_column_metadata(
            db_name, cols, is_view, table_name, key_properties)
        assert_that(actual_mdata, equal_to(metadata.to_list(expected_mdata)))
 def test_type_date_time(self):
     col = sample_db_data['columns'][6]
     column_schema = tap_redshift.schema_for_column(col).to_dict()
     stream_schema = expected_result['streams'][0]
     expected_schema = stream_schema['schema']['properties']['created_at']
     assert_that(column_schema, equal_to(expected_schema))
 def test_type_int4(self):
     col = sample_db_data['columns'][0]
     column_schema = tap_redshift.schema_for_column(col).to_dict()
     ppt = expected_result['streams'][0]['schema']['properties']['id']
     expected_schema = ppt
     assert_that(column_schema, equal_to(expected_schema))