test_client.py 文件源码

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

项目:python-moira-client 作者: moira-alert 项目源码 文件源码
def test_put_invalid_response(self):
        test_data = {'test': 'test'}

        def put(url, data, **kwargs):
            return FakeResponse()

        response = FakeResponse()

        with patch.object(requests, 'put', side_effects=put, return_value=response) as mock_put:
            test_path = 'test_path'

            client = Client(TEST_API_URL, AUTH_HEADERS)
            with self.assertRaises(InvalidJSONError):
                client.put(test_path, data=test_data)

        self.assertTrue(mock_put.called)
        expected_url_call = TEST_API_URL + '/' + test_path
        mock_put.assert_called_with(expected_url_call, data=test_data, headers=AUTH_HEADERS, auth=None)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号