diff --git a/bigframes/constants.py b/bigframes/constants.py index 3c18fd20bd..d6fe699713 100644 --- a/bigframes/constants.py +++ b/bigframes/constants.py @@ -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 diff --git a/tests/unit/test_constants.py b/tests/unit/test_constants.py new file mode 100644 index 0000000000..aabc09c388 --- /dev/null +++ b/tests/unit/test_constants.py @@ -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 diff --git a/tests/unit/test_formatting_helpers.py b/tests/unit/test_formatting_helpers.py index 9db9b372e2..3c966752c9 100644 --- a/tests/unit/test_formatting_helpers.py +++ b/tests/unit/test_formatting_helpers.py @@ -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) diff --git a/third_party/bigframes_vendored/constants.py b/third_party/bigframes_vendored/constants.py index 0d4a7d1df6..91084b38f9 100644 --- a/third_party/bigframes_vendored/constants.py +++ b/third_party/bigframes_vendored/constants.py @@ -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 = (