def test_get(self):
"""Test get method"""
interface = self._test_azureiothttps()
appif = self._test_appinterface()
interface.appinterface = appif
interfaceManager.interfaces = [interface]
with patch.object(reqparse.RequestParser, 'parse_args'):
resource = RestAppInterface(restapi=self.restapi, server=self.server)
# Fail to find the app interface: raises 404 NotFound
interfaceManager.getInterface = MagicMock(return_value=None)
yield self.assertFailure(resource.get(1), e.NotFound)
# Success finding the interface returns a dict of field values
interfaceManager.getInterface = MagicMock(return_value=interface)
result = yield resource.get(appif.id)
self.assertEqual(interface.name, result['name'])
评论列表
文章目录