test_restgateway.py 文件源码

python
阅读 18 收藏 0 点赞 0 评论 0

项目:floranet 作者: Fluent-networks 项目源码 文件源码
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'])
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号