Skip to content

Commit

Permalink
add test for new Status.from_json classmethod
Browse files Browse the repository at this point in the history
  • Loading branch information
eriktaubeneck committed Sep 26, 2024
1 parent 373de17 commit bbfa409
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion sidecar/app/query/status.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def from_json(cls, response: dict[str, str]):
status_str = response.get("status", "")
try:
return cls[status_str]
except ValueError:
except KeyError:
return cls.UNKNOWN


Expand Down
16 changes: 16 additions & 0 deletions sidecar/tests/app/query/test_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,3 +113,19 @@ def test_status_history_status_event_json(
"start_time": now,
"end_time": now2,
}


def test_status_from_json():
# matching string
status = Status.from_json({"status": "STARTING"})
assert status == Status.STARTING
status = Status.from_json({"status": "UNKNOWN"})
assert status == Status.UNKNOWN

# non-mathcing string
status = Status.from_json({"status": "not-a-status"})
assert status == Status.UNKNOWN

# empty json
status = Status.from_json({})
assert status == Status.UNKNOWN

0 comments on commit bbfa409

Please sign in to comment.