From acca1cb7baaa3b00508246c994ade40314d421c3 Mon Sep 17 00:00:00 2001 From: Peter Lamut Date: Mon, 13 Sep 2021 16:28:53 +0200 Subject: [PATCH] feat: include key metadata in Job representation (#964) --- google/cloud/bigquery/job/base.py | 8 ++++++++ tests/unit/job/test_base.py | 6 ++++++ 2 files changed, 14 insertions(+) diff --git a/google/cloud/bigquery/job/base.py b/google/cloud/bigquery/job/base.py index e5fc592a6..72db5a63c 100644 --- a/google/cloud/bigquery/job/base.py +++ b/google/cloud/bigquery/job/base.py @@ -722,6 +722,14 @@ def cancelled(self): and self.error_result.get("reason") == _STOPPED_REASON ) + def __repr__(self): + result = ( + f"{self.__class__.__name__}<" + f"project={self.project}, location={self.location}, id={self.job_id}" + ">" + ) + return result + class _JobConfig(object): """Abstract base class for job configuration objects. diff --git a/tests/unit/job/test_base.py b/tests/unit/job/test_base.py index aa8e9c045..e320c72cb 100644 --- a/tests/unit/job/test_base.py +++ b/tests/unit/job/test_base.py @@ -1043,6 +1043,12 @@ def test_cancelled_w_error_result_w_stopped(self): self.assertTrue(job.cancelled()) + def test_repr(self): + client = _make_client(project="project-foo") + job = self._make_one("job-99", client) + job._properties.setdefault("jobReference", {})["location"] = "ABC" + assert repr(job) == "_AsyncJob" + class Test_JobConfig(unittest.TestCase): JOB_TYPE = "testing"