def connection_mock_factory(mocker):
    """Factory of DB connection mocks."""
    def factory(vendor, fetch_one_result=None):
        connection_mock = mocker.MagicMock(vendor=vendor)
        cursor_mock = connection_mock.cursor.return_value
        cursor_mock = cursor_mock.__enter__.return_value  # noqa: WPS609
        cursor_mock.fetchone.return_value = fetch_one_result
        return connection_mock
    return factory