Skip to content

Commit

Permalink
include response for invalid attribute in setUpPort
Browse files Browse the repository at this point in the history
  • Loading branch information
carueda committed Oct 3, 2012
1 parent a2cbc28 commit 030ff06
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion ion/agents/platform/oms/simulator/oms_simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,6 @@ def setUpPort(self, platform_id, port_id, attributes):

port_attrs = self._idp[platform_id].get_port(port_id).attrs

# result will contain the attributes that were set
result = {}
for key, val in attributes.iteritems():
if key in VALID_PORT_ATTRIBUTES:
Expand All @@ -218,6 +217,7 @@ def setUpPort(self, platform_id, port_id, attributes):
# 2. in the result, indicate that the value was set:
result[key] = val
else:
result[key] = InvalidResponse.ATTRIBUTE_NAME
log.warn("setUpPort called with unrecognized attribute: %s"% key)

return {platform_id: {port_id: result}}
Expand Down
9 changes: 6 additions & 3 deletions ion/agents/platform/oms/test/oms_test_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,10 +224,13 @@ def test_am_setUpPort(self):
ports = self._verify_valid_platform_id(platform_id, retval)
port_val = self._verify_valid_port_id(port_id, ports)
self.assertIsInstance(port_val, dict)
for attr_name in valid_attributes:
for attr_name in all_attributes:
self.assertTrue(attr_name in port_val)
for attr_name in invalid_attributes:
self.assertFalse(attr_name in port_val)
attr_val = port_val[attr_name]
if attr_name in valid_attributes:
self.assertTrue(attr_val is not None) # TODO more specific check
else:
self.assertEquals(InvalidResponse.ATTRIBUTE_NAME, attr_val)

def test_am_setUpPort_invalid_platform_id(self):
platform_id = BOGUS_PLATFORM_ID
Expand Down

0 comments on commit 030ff06

Please sign in to comment.