Example #1
0
def test_streaming_transformer_schema_get_identity_error(schema_loader: SchemaLoader,
                                                         schema_spec: Dict[str, Any]) -> None:
    schema_spec['Identity'] = 'source.user'
    streaming_bts = schema_loader.add_schema_spec(schema_spec)
    transformer_schema = StreamingTransformerSchema(streaming_bts, schema_loader)
    with pytest.raises(IdentityError, match='Could not determine identity using source.user'):
        assert transformer_schema.get_identity(Record())
def test_streaming_transformer_schema_get_identity_from_record(
        schema_loader: SchemaLoader, schema_spec: Dict[str, Any]) -> None:
    schema_spec['Identity'] = 'source.user'
    streaming_dtc = schema_loader.add_schema_spec(schema_spec)
    transformer_schema = StreamingTransformerSchema(streaming_dtc,
                                                    schema_loader)
    assert transformer_schema.get_identity(Record({'user':
                                                   '******'})) == 'user1'
def test_streaming_transformer_schema_get_identity_constant(
        schema_loader: SchemaLoader, schema_spec: Dict[str, Any]) -> None:
    streaming_dtc = schema_loader.add_schema_spec(schema_spec)
    transformer_schema = StreamingTransformerSchema(streaming_dtc,
                                                    schema_loader)
    assert transformer_schema.get_identity(Context()) == 'user1'