8000 feat: include the bigframes package version alongside the feedback link in error messages by rey-esp · Pull Request #936 · googleapis/python-bigquery-dataframes · GitHub
[go: up one dir, main page]

Skip to content
1 change: 1 addition & 0 deletions bigframes/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import bigframes_vendored.constants

BF_VERSION = bigframes_vendored.constants.BF_VERSION
FEEDBACK_LINK = bigframes_vendored.constants.FEEDBACK_LINK
ABSTRACT_METHOD_ERROR_MESSAGE = (
bigframes_vendored.constants.ABSTRACT_METHOD_ERROR_MESSAGE
Expand Down
20 changes: 20 additions & 0 deletions tests/unit/test_constants.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright 2023 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import bigframes.constants as constants


def test_feedback_link_includes_version():
assert len(constants.BF_VERSION) > 0
assert constants.BF_VERSION in constants.FEEDBACK_LINK
11 changes: 11 additions & 0 deletions tests/unit/test_formatting_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,14 @@ def test_wait_for_job_error_includes_feedback_link():

cap_exc.match("Test message 123.")
cap_exc.match(constants.FEEDBACK_LINK)


def test_wait_for_job_error_includes_version():
mock_job = mock.create_autospec(bigquery.LoadJob)
mock_job.result.side_effect = api_core_exceptions.BadRequest("Test message 123.")

with pytest.raises(api_core_exceptions.BadRequest) as cap_exc:
formatting_helpers.wait_for_job(mock_job)

cap_exc.match("Test message 123.")
cap_exc.match(constants.BF_VERSION)
4 changes: 4 additions & 0 deletions third_party/bigframes_vendored/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,14 @@

This module should not depend on any others in the package.
"""
import bigframes.version

BF_VERSION = bigframes.version.__version__

FEEDBACK_LINK = (
"Share your usecase with the BigQuery DataFrames team at the "
"https://bit.ly/bigframes-feedback survey."
f"You are currently running BigFrames version {BF_VERSION}"
)

ABSTRACT_METHOD_ERROR_MESSAGE = (
Expand Down
0