Skip to content

Commit

Permalink
Fixes for code review
Browse files Browse the repository at this point in the history
  • Loading branch information
Tokunbo committed Feb 14, 2015
1 parent cb2f928 commit 4f7ab01
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion mimic/canned_responses/maas_agent_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def agent_info(entity_id, agent_id):
{
"agent_id": agent_id,
"entity_id": entity_id,
"entity_uri": "https://ord.servers.api.mimic.co.jp/"+agent_id,
"entity_uri": "https://ord.servers.api.mimic.co.jp/" + agent_id,
"host_info": {
"memory": {
"timestamp": 1423092674788,
Expand Down
8 changes: 8 additions & 0 deletions mimic/rest/maas_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -625,6 +625,14 @@ def view_agent_host_info(self, request, tenant_id):
Return 400 until the fifth attempt, then start to return data as if the
Agent is truly installed and working.
"""
if 'entityId' not in request.args:
request.setResponseCode(400)
return json.dump({'type': 'badRequest',
'code': 400,
'message': 'Validation error for key \'agentId, entityId, uri\'',
'details': 'You must specify an agentId, entityId, or an entity URI.',
'mimicNotes': 'But mimic will only accept entityId right now',
"txnId": ".fake.mimic.transaction.id.c-1111111.ts-123444444.v-12344frf"})
entity_id = request.args['entityId'][0].strip()
for e in self._entity_cache_for_tenant(tenant_id).entities_list:
if e['id'] == entity_id:
Expand Down
4 changes: 2 additions & 2 deletions mimic/test/test_maas.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,13 +333,13 @@ def test_agenthostinfo(self):
"""
for q in range(4):
req = request(self, self.root, "GET",
self.uri + '/views/agent_host_info?entityId='+self.entity_id)
self.uri + '/views/agent_host_info?entityId=' + self.entity_id)
resp = self.successResultOf(req)
self.assertEquals(resp.code, 400)
data = self.get_responsebody(resp)
self.assertEquals(True, 'Agent does not exist' in json.dumps(data))
req = request(self, self.root, "GET",
self.uri + '/views/agent_host_info?entityId='+self.entity_id, '')
self.uri + '/views/agent_host_info?entityId=' + self.entity_id)
resp = self.successResultOf(req)
self.assertEquals(resp.code, 200)
data = self.get_responsebody(resp)
Expand Down

0 comments on commit 4f7ab01

Please sign in to comment.