def test_host_creds_retrieve(self):
"""
Verify retrieving Host Credentials.
"""
with mock.patch('cherrypy.engine.publish') as _publish:
manager = mock.MagicMock(StoreHandlerManager)
_publish.return_value = [manager]
# Verify if the host exists the data is returned
manager.get.return_value = make_new(HOST)
body = self.simulate_request('/api/v0/host/10.2.0.2/creds')
# datasource's get should have been called once
self.assertEqual(self.srmock.status, falcon.HTTP_200)
self.assertEqual(
json.loads(HOST_CREDS_JSON),
json.loads(body[0]))
# Verify no host returns the proper result
manager.reset_mock()
manager.get.side_effect = Exception
body = self.simulate_request('/api/v0/host/10.9.9.9/creds')
self.assertEqual(self.srmock.status, falcon.HTTP_404)
self.assertEqual({}, json.loads(body[0]))
test_handlers_hosts.py 文件源码
python
阅读 18
收藏 0
点赞 0
评论 0
评论列表
文章目录