diff --git a/brewtils/models.py b/brewtils/models.py index 5c2aa1f6..302e5adb 100644 --- a/brewtils/models.py +++ b/brewtils/models.py @@ -457,7 +457,7 @@ def set_status_heartbeat(self, status, max_history=None): self.heartbeat = datetime.utcnow() self.history.append(StatusHistory(status=copy.deepcopy(status), heartbeat=self.heartbeat)) - if max_history and len(self.history) > max_history: + if max_history and max_history > 0 and len(self.history) > max_history: self.history = self.history[(max_history * -1):] def __str__(self): diff --git a/test/models_test.py b/test/models_test.py index 0946f559..6d3e84f3 100644 --- a/test/models_test.py +++ b/test/models_test.py @@ -735,3 +735,11 @@ def test_history(self): status_info.set_status_heartbeat("RUNNING") assert len(status_info.history) == 10 + + def test_negative_history(self): + status_info = StatusInfo() + + for _ in range(10): + status_info.set_status_heartbeat("RUNNING", max_history=-1) + + assert len(status_info.history) == 10