test_flask_util.py 文件源码

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

项目:REMAP 作者: REMAPApp 项目源码 文件源码
def test_callback_view(self):
        self.oauth2.storage = mock.Mock()
        with self.app.test_client() as client:
            with mock.patch(
                    'oauth2client.transport.get_http_object') as new_http:
                # Set-up mock.
                http = http_mock.HttpMock(data=DEFAULT_RESP)
                new_http.return_value = http
                # Run tests.
                state = self._setup_callback_state(client)

                response = client.get(
                    '/oauth2callback?state={0}&code=codez'.format(state))

                self.assertEqual(response.status_code, httplib.FOUND)
                self.assertIn('/return_url', response.headers['Location'])
                self.assertIn(self.oauth2.client_secret, http.body)
                self.assertIn('codez', http.body)
                self.assertTrue(self.oauth2.storage.put.called)

                # Check the mocks were called.
                new_http.assert_called_once_with()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号