Skip to content

Commit

Permalink
Merge pull request tableau#1448 from jorwoods/jorwoods/jobitem_repr
Browse files Browse the repository at this point in the history
fix: JobItem repr
  • Loading branch information
jacalata authored Sep 2, 2024
2 parents 4cf1916 + 3c3c5b3 commit 6053bdc
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
4 changes: 2 additions & 2 deletions tableauserverclient/models/job_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from defusedxml.ElementTree import fromstring

from tableauserverclient.datetime_helpers import parse_datetime
from .flow_run_item import FlowRunItem
from tableauserverclient.models.flow_run_item import FlowRunItem


class JobItem(object):
Expand Down Expand Up @@ -222,7 +222,7 @@ def __init__(
self._subtitle = subtitle

def __str__(self):
return f"<{self.__class__.name} {self._id} {self._type}>"
return f"<{self.__class__.__qualname__} {self._id} {self._type}>"

def __repr__(self):
return self.__str__() + " { " + ", ".join(" % s: % s" % item for item in vars(self).items()) + "}"
Expand Down
8 changes: 4 additions & 4 deletions tableauserverclient/server/endpoint/jobs_endpoint.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import logging
from typing_extensions import Self, overload

from tableauserverclient.server.query import QuerySet

from .endpoint import QuerysetEndpoint, api
from .exceptions import JobCancelledException, JobFailedException
from tableauserverclient.models import JobItem, BackgroundJobItem, PaginationItem
from ..request_options import RequestOptionsBase
from tableauserverclient.server.endpoint.endpoint import QuerysetEndpoint, api
from tableauserverclient.server.endpoint.exceptions import JobCancelledException, JobFailedException
from tableauserverclient.server.query import QuerySet
from tableauserverclient.server.request_options import RequestOptionsBase
from tableauserverclient.exponential_backoff import ExponentialBackoffTimer

from tableauserverclient.helpers.logging import logger
Expand Down
8 changes: 8 additions & 0 deletions test/test_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,3 +136,11 @@ def test_get_job_datasource_name(self) -> None:
m.get(f"{self.baseurl}/{job_id}", text=response_xml)
job = self.server.jobs.get_by_id(job_id)
self.assertEqual(job.datasource_name, "World Indicators")

def test_background_job_str(self) -> None:
job = TSC.BackgroundJobItem(
"ee8c6e70-43b6-11e6-af4f-f7b0d8e20760", datetime.now(), 1, "extractRefresh", "Failed"
)
assert not str(job).startswith("<<property")
assert not repr(job).startswith("<<property")
assert "BackgroundJobItem" in str(job)

0 comments on commit 6053bdc

Please sign in to comment.