def test_request_view(self):

        request_patcher = mock.patch('flaskext.gae_mini_profiler.request',
                                     spec=True)
        profiler_patcher = mock.patch('flaskext.gae_mini_profiler.profiler',
                                      spec=True)
        jsonify_patcher = mock.patch('flaskext.gae_mini_profiler.jsonify',
                                     spec=True)

        request = request_patcher.start()
        profiler = profiler_patcher.start()
        jsonify = jsonify_patcher.start()

        try:
            from flaskext.gae_mini_profiler import GAEMiniProfiler
            properties = ['a', 'b', 'c']

            request_ids = ['1', '2', '3']
            request.args = {'request_ids': ','.join(request_ids)}

            stats = profiler.RequestStats.get.return_value
            stats.__getattribute__ = lambda x: x
            stats.disabled = False
            stats.temporary_redirect = False

            profiler.RequestStats.serialized_properties = properties
            app = mock.Mock()
            ext = GAEMiniProfiler(app)
            ext._request_view()

            self.assertEquals(len(request_ids),
                              profiler.RequestStats.get.call_count)

            expected_result = []
            for id in request_ids:
                expected_result.append(dict(zip(properties, properties)))

            jsonify.assert_called_once_with(stats=expected_result)
        finally:
            request_patcher.stop()
            profiler_patcher.stop()
            jsonify_patcher.stop()
Test the request stats view
dataset/ETHPy150Open passy/flask-gae-mini-profiler/tests/extension.py/ExtensionTestCase.test_request_view