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