Exemplo n.º 1
0
def test_update_existing_client(mocker):
    project = mocker.MagicMock()
    _get_project_for_url_or_path = mocker.patch(
        "openapi_python_client._get_project_for_url_or_path",
        return_value=project)
    url = mocker.MagicMock()
    path = mocker.MagicMock()

    from openapi_python_client import update_existing_client

    update_existing_client(url=url, path=path)

    _get_project_for_url_or_path.assert_called_once_with(url=url, path=path)
    project.update.assert_called_once()
Exemplo n.º 2
0
def test_update_existing_client(mocker):
    project = mocker.MagicMock()
    _get_project_for_url_or_path = mocker.patch(
        "openapi_python_client._get_project_for_url_or_path",
        return_value=project)
    url = mocker.MagicMock()
    path = mocker.MagicMock()
    config = mocker.MagicMock()

    from openapi_python_client import MetaType, update_existing_client

    result = update_existing_client(url=url,
                                    path=path,
                                    meta=MetaType.POETRY,
                                    config=config)

    _get_project_for_url_or_path.assert_called_once_with(
        url=url,
        path=path,
        custom_template_path=None,
        meta=MetaType.POETRY,
        file_encoding="utf-8",
        config=config)
    project.update.assert_called_once()
    assert result == project.update.return_value
def test_update_existing_client_project_error(mocker):
    error = GeneratorError()
    _get_project_for_url_or_path = mocker.patch(
        "openapi_python_client._get_project_for_url_or_path",
        return_value=error)
    url = mocker.MagicMock()
    path = mocker.MagicMock()

    from openapi_python_client import update_existing_client

    result = update_existing_client(url=url, path=path)

    _get_project_for_url_or_path.assert_called_once_with(url=url, path=path)
    assert result == [error]
Exemplo n.º 4
0
def test_update_existing_client_project_error(mocker):
    error = GeneratorError()
    _get_project_for_url_or_path = mocker.patch(
        "openapi_python_client._get_project_for_url_or_path",
        return_value=error)
    url = mocker.MagicMock()
    path = mocker.MagicMock()

    from openapi_python_client import MetaType, update_existing_client

    result = update_existing_client(url=url, path=path, meta=MetaType.POETRY)

    _get_project_for_url_or_path.assert_called_once_with(
        url=url, path=path, custom_template_path=None, meta=MetaType.POETRY)
    assert result == [error]