Skip to content

Commit

Permalink
model cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
TheBurchLog committed Jul 10, 2024
1 parent 76118c0 commit d24476c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
26 changes: 23 additions & 3 deletions brewtils/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ def __init__(
self.description = description
self.id = id
self.status = status.upper() if status else None
self.status_info = status_info or {}
self.status_info = status_info
self.queue_type = queue_type
self.queue_info = queue_info or {}
self.icon_name = icon_name
Expand Down Expand Up @@ -431,6 +431,18 @@ def __init__(self, status=None, heartbeat=None):
self.status = status
self.heartbeat = heartbeat

def __str__(self):
return "%s:%s" % (
self.status,
self.heartbeat,
)

def __repr__(self):
return "<StatusHistory: status=%s, heartbeat=%s>" % (
self.status,
self.heartbeat,
)


class StatusInfo(BaseModel):
schema = "StatusInfoSchema"
Expand All @@ -444,6 +456,14 @@ def set_status_heartbeat(self, status):
self.heartbeat = datetime.utcnow()
self.history.append(StatusHistory(status=status, heartbeat=self.heartbeat))

def __str__(self):
return self.heartbeat

def __repr__(self):
return "<StatusInfo: heartbeat=%s, history=%s>" % (
self.heartbeat,
self.history,
)

class RequestFile(BaseModel):
schema = "RequestFileSchema"
Expand Down Expand Up @@ -1497,7 +1517,7 @@ def __init__(
self.id = id
self.name = name
self.status = status.upper() if status else None
self.status_info = status_info or {}
self.status_info = status_info
self.namespaces = namespaces or []
self.systems = systems or []

Expand Down Expand Up @@ -1554,7 +1574,7 @@ def __init__(
):
self.api = api
self.status = status
self.status_info = status_info or {}
self.status_info = status_info
self.config = config or {}

def __str__(self):
Expand Down
2 changes: 1 addition & 1 deletion brewtils/test/comparable.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ def assert_status_info_equal(obj1, obj2, do_raise=False):
obj2,
expected_type=StatusInfo,
deep_fields={
"status_history": partial(assert_status_history_equal, do_raise=True),
"history": partial(assert_status_history_equal, do_raise=True),
},
do_raise=do_raise,
)
Expand Down

0 comments on commit d24476c

Please sign in to comment.