def test_get(self):
"""Test get method"""
gateway = self._test_gateway()
mockDBObject.return_value = gateway
with patch.object(reqparse.RequestParser, 'parse_args'):
resource = RestGateway(restapi=self.restapi, server=self.server)
# Fail to find a gateway: raises 404 NotFound
with patch.object(Gateway, 'find', classmethod(mockDBObject.findFail)):
yield self.assertFailure(resource.get(gateway.host), e.NotFound)
# Find a device success returns a dict of field values
with patch.object(Gateway, 'find', classmethod(mockDBObject.findSuccess)):
result = yield resource.get(gateway.host)
self.assertEqual(gateway.host, result['host'])
评论列表
文章目录