Beispiel #1
0
def test_capture_environment_from_config_none(mock_upload_conda_env,
                                              mock_upload_pip_env):
    with fake_creds(extra={"DEFAULT_CONFIG": {"environment": None}}):
        _capture_environment("auto", "fake_gist_slug", 2)

        mock_upload_conda_env.assert_not_called()
        mock_upload_pip_env.assert_not_called()
def test_capture_environment_conda_error_and_pip_exception(mock_upload_conda_env, mock_upload_pip_env, capsys):

    def conda_error_raiser(*args, **kwargs):
        raise CondaError('fake conda error')

    def pip_exception_raiser(*args, **kwargs):
        raise Exception('fake pip error')

    mock_upload_conda_env.side_effect = conda_error_raiser
    mock_upload_pip_env.side_effect = pip_exception_raiser

    _capture_environment('auto', 'fake_gist_slug', 2)

    mock_upload_conda_env.assert_called_with('fake_gist_slug', 2)
    mock_upload_pip_env.assert_called_with('fake_gist_slug', 2)

    expected_result = dedent("""
            [jovian] Error: fake conda error
            [jovian] Error: fake pip error
            """).strip()
    captured = capsys.readouterr()
    assert captured.err.strip() == expected_result
def test_capture_environment_from_config(environment, env_config, mock_upload):
    with fake_creds(extra={"DEFAULT_CONFIG": {"environment": env_config}}), mock.patch(mock_upload) as mock_upload:
        _capture_environment(environment, 'fake_gist_slug', 2)
        mock_upload.assert_called_with('fake_gist_slug', 2)
def test_capture_environment(mock_upload_conda_env):
    with fake_creds():
        _capture_environment('conda', 'fake_gist_slug', 2)

        mock_upload_conda_env.assert_called_with('fake_gist_slug', 2)