Ejemplo n.º 1
0
def test_validate_field_appears_at_least_once(records, configured_catalog, expected_error):
    t = _TestBasicRead()
    if expected_error:
        with pytest.raises(AssertionError, match=expected_error):
            t._validate_field_appears_at_least_once(records=records, configured_catalog=configured_catalog)
    else:
        t._validate_field_appears_at_least_once(records=records, configured_catalog=configured_catalog)
Ejemplo n.º 2
0
def test_read(schema, record, should_fail):
    catalog = ConfiguredAirbyteCatalog(streams=[
        ConfiguredAirbyteStream(
            stream=AirbyteStream.parse_obj({
                "name": "test_stream",
                "json_schema": schema
            }),
            sync_mode="full_refresh",
            destination_sync_mode="overwrite",
        )
    ])
    input_config = BasicReadTestConfig()
    docker_runner_mock = MagicMock()
    docker_runner_mock.call_read.return_value = [
        AirbyteMessage(type=Type.RECORD,
                       record=AirbyteRecordMessage(stream="test_stream",
                                                   data=record,
                                                   emitted_at=111))
    ]
    t = _TestBasicRead()
    if should_fail:
        with pytest.raises(
                AssertionError,
                match="stream should have some fields mentioned by json schema"
        ):
            t.test_read(None, catalog, input_config, [], docker_runner_mock,
                        MagicMock())
    else:
        t.test_read(None, catalog, input_config, [], docker_runner_mock,
                    MagicMock())
Ejemplo n.º 3
0
def test_airbyte_trace_message_on_failure(output, expect_trace_message_on_failure, should_fail):
    t = _TestBasicRead()
    input_config = BasicReadTestConfig(expect_trace_message_on_failure=expect_trace_message_on_failure)
    docker_runner_mock = MagicMock()
    docker_runner_mock.call_read.return_value = output

    with patch.object(pytest, "skip", return_value=None):
        if should_fail:
            with pytest.raises(AssertionError, match="Connector should emit at least one error trace message"):
                t.test_airbyte_trace_message_on_failure(None, input_config, docker_runner_mock)
        else:
            t.test_airbyte_trace_message_on_failure(None, input_config, docker_runner_mock)