test_http_screen.py 文件源码

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

项目:ussd_airflow 作者: mwaaas 项目源码 文件源码
def test(self, mock_request):
        mock_response = JsonResponse({"balance": 250})
        mock_request.return_value = mock_response
        ussd_client = self.ussd_client()

        self.assertEqual(
            "Testing response is being saved in "
            "session status code is 200 and "
            "balance is 250 and full content {'balance': 250}.\n",
            ussd_client.send('')
        )
        expected_calls = [
            mock.call(
                method='get',
                url="http://localhost:8000/mock/balance",
                params=dict(
                    phone_number="200",
                    session_id=ussd_client.session_id
                ),
                verify=False,
                headers={"content-type": "application/json",
                         "user-agent": "my-app/0.0.1"}
            ),
            mock.call(
                method="get",
                url="http://localhost:8000/mock/balance/200/"
            ),
            mock.call(
                method='post',
                url='http://localhost:8000/mock/balance',
                params=dict(
                    phone_numbers=[200, 201, 202],
                    session_id=ussd_client.session_id
                ),
                verify=True,
                timeout=30,
                headers={"content-type": "application/json"}
            )
        ]
        # test requests that were made
        mock_request.assert_has_calls(expected_calls)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号