Skip to content

Commit

Permalink
Fix api/v1/status output format
Browse files Browse the repository at this point in the history
We should return data in different format
  • Loading branch information
boris-42 committed Dec 6, 2016
1 parent a209151 commit 3d403d5
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
2 changes: 1 addition & 1 deletion ceagle/api/v1/status.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def get_status_helper(period, region=None):
"health": None, "performance": None})

result[r][service_name] = value[key_map[service_name]["arg"]]
return result
return {"period": period, "status": result}


@bp_status.route("/<period>")
Expand Down
26 changes: 18 additions & 8 deletions tests/unit/api/v1/test_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,10 +182,15 @@ def test_get_status(self, mock_client, mock_config):
"/api/v1/health/day")
mock_avail_client.get.assert_called_once_with(
"/api/v1/availability/day")
expected = {"bar": {"availability": 24, "health": None,
"performance": None, "sla": None},
"foo": {"availability": None, "health": 42,
"performance": None, "sla": None}}
expected = {
"period": "day",
"status": {
"bar": {"availability": 24, "health": None,
"performance": None, "sla": None},
"foo": {"availability": None, "health": 42,
"performance": None, "sla": None}
}
}
self.assertEqual(expected, resp)

@mock.patch("ceagle.api.v1.status.config.get_config")
Expand All @@ -209,8 +214,13 @@ def test_get_region_status(self, mock_client, mock_config):
"/api/v1/region/foo_region/health/day")
mock_avail_client.get.assert_called_once_with(
"/api/v1/region/foo_region/availability/day")
expected = {"bar": {"availability": 24, "health": None,
"performance": None, "sla": None},
"foo": {"availability": None, "health": 42,
"performance": None, "sla": None}}
expected = {
"period": "day",
"status": {
"bar": {"availability": 24, "health": None,
"performance": None, "sla": None},
"foo": {"availability": None, "health": 42,
"performance": None, "sla": None}
}
}
self.assertEqual(expected, resp)

0 comments on commit 3d403d5

Please sign in to comment.