def test_replace(self): kwargs = { 'type': None, 'path': { 'database': 'test-project', 'schema': 'test_schema', 'identifier': 'my_view' }, # test for #2188 'quote_policy': { 'database': False }, 'include_policy': { 'database': True, 'schema': True, 'identifier': True, } } BigQueryRelation.validate(kwargs) relation = BigQueryRelation.from_dict(kwargs) info_schema = relation.information_schema() tables_schema = info_schema.replace( information_schema_view='__TABLES__') assert tables_schema.information_schema_view == '__TABLES__' assert tables_schema.include_policy.schema is True assert tables_schema.include_policy.identifier is False assert tables_schema.include_policy.database is True assert tables_schema.quote_policy.schema is True assert tables_schema.quote_policy.identifier is False assert tables_schema.quote_policy.database is False schemata_schema = info_schema.replace( information_schema_view='SCHEMATA') assert schemata_schema.information_schema_view == 'SCHEMATA' assert schemata_schema.include_policy.schema is False assert schemata_schema.include_policy.identifier is True assert schemata_schema.include_policy.database is True assert schemata_schema.quote_policy.schema is True assert schemata_schema.quote_policy.identifier is False assert schemata_schema.quote_policy.database is False other_schema = info_schema.replace( information_schema_view='SOMETHING_ELSE') assert other_schema.information_schema_view == 'SOMETHING_ELSE' assert other_schema.include_policy.schema is True assert other_schema.include_policy.identifier is True assert other_schema.include_policy.database is True assert other_schema.quote_policy.schema is True assert other_schema.quote_policy.identifier is False assert other_schema.quote_policy.database is False
def test_view_temp_relation(self): kwargs = { 'type': None, 'path': { 'database': 'test-project', 'schema': 'test_schema', 'identifier': 'my_view' }, 'quote_policy': { 'identifier': False } } BigQueryRelation.validate(kwargs)
def test_external_source_relation(self): kwargs = { 'type': 'external', 'path': { 'database': 'test-project', 'schema': 'test_schema', 'identifier': 'sheet' }, 'quote_policy': { 'identifier': True, 'schema': True } } BigQueryRelation.validate(kwargs)
def test_table_relation(self): kwargs = { 'type': 'table', 'path': { 'database': 'test-project', 'schema': 'test_schema', 'identifier': 'generic_table' }, 'quote_policy': { 'identifier': True, 'schema': True } } BigQueryRelation.validate(kwargs)
def test_invalid_relation(self): kwargs = { 'type': 'invalid-type', 'path': { 'database': 'test-project', 'schema': 'test_schema', 'identifier': 'my_invalid_id' }, 'quote_policy': { 'identifier': False, 'schema': True } } with self.assertRaises(dbt.dataclass_schema.ValidationError): BigQueryRelation.validate(kwargs)