Skip to content

Commit

Permalink
Updating Job Model
Browse files Browse the repository at this point in the history
  • Loading branch information
TheBurchLog committed Jun 7, 2024
1 parent 3012d93 commit 23cc356
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
12 changes: 7 additions & 5 deletions brewtils/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1209,6 +1209,7 @@ def __init__(
status=None,
max_instances=None,
timeout=None,
replication_id=None,
):
self.id = id
self.name = name
Expand All @@ -1225,6 +1226,7 @@ def __init__(
self.status = status
self.max_instances = max_instances
self.timeout = timeout
self.replication_id = replication_id

def __str__(self):
return "%s: %s" % (self.name, self.id)
Expand Down Expand Up @@ -1729,16 +1731,16 @@ def __repr__(self):
class Replication(BaseModel):
schema = "ReplicationSchema"

def __init__(self, id=None, replication_id=None, heartbeat=None):
def __init__(self, id=None, replication_id=None, expires_at=None):
self.id = id
self.replication_id = replication_id
self.heartbeat = heartbeat
self.expires_at = expires_at

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

def __repr__(self):
return "<Replication: replication_id=%s, heartbeat=%s>" % (
return "<Replication: replication_id=%s, expires_at=%s>" % (
self.replication_id,
self.heartbeat,
self.expires_at,
)
3 changes: 2 additions & 1 deletion brewtils/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,7 @@ class JobSchema(BaseSchema):
status = fields.Str(allow_none=True)
max_instances = fields.Int(allow_none=True)
timeout = fields.Int(allow_none=True)
replication_id = fields.Str(allow_none=True)


class JobExportInputSchema(BaseSchema):
Expand Down Expand Up @@ -645,7 +646,7 @@ class TopicSchema(BaseSchema):
class ReplicationSchema(BaseSchema):
id = fields.Str(allow_none=True)
replication_id = fields.Str(allow_none=True)
heartbeat = DateTime(allow_none=True, format="epoch", example="1500065932000")
expires_at = DateTime(allow_none=True, format="epoch", example="1500065932000")


class UserSchema(BaseSchema):
Expand Down
5 changes: 3 additions & 2 deletions brewtils/test/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -584,6 +584,7 @@ def job_dict(ts_epoch, request_template_dict, date_trigger_dict):
"status": "RUNNING",
"max_instances": 3,
"timeout": 30,
"replication_id": "123"
}


Expand Down Expand Up @@ -945,12 +946,12 @@ def replication_dict(ts_epoch):
return {
"id": "1234",
"replication_id": "89cd6a3a-e0e2-486b-b8e8-535d1893faf3",
"heartbeat": ts_epoch,
"expires_at": ts_epoch,
}


@pytest.fixture
def bg_replication(replication_dict, ts_dt):
dict_copy = copy.deepcopy(replication_dict)
dict_copy["heartbeat"] = ts_dt
dict_copy["expires_at"] = ts_dt
return Replication(**dict_copy)

0 comments on commit 23cc356

Please sign in to comment.