async def test_dont_send_hook_on_folder_metadata(self, handler):
        handler.request.method = 'GET'
        handler.path = WaterButlerPath('/folder/')
        handler._send_hook = mock.Mock()

        assert handler.on_finish() is None
        assert not handler._send_hook.called
Esempio n. 2
0
    async def test_dont_send_hook_on_file_metadata(self, handler):
        handler.request.query_arguments['meta'] = ''
        handler.request.method = 'GET'
        handler._send_hook = mock.Mock()

        assert handler.on_finish() is None
        assert not handler._send_hook.called
    async def test_dont_send_hook_on_file_metadata(self, handler):
        handler.request.query_arguments['meta'] = ''
        handler.request.method = 'GET'
        handler._send_hook = mock.Mock()

        assert handler.on_finish() is None
        assert not handler._send_hook.called
    async def test_on_finish_delete(self, handler):
        handler.request.method = 'DELETE'
        handler.target_path = WaterButlerPath('/file')
        handler._send_hook = mock.Mock()

        assert handler.on_finish() is None
        handler._send_hook.assert_called_once_with('delete')
    async def test_on_finish_update(self, handler):
        handler.request.method = 'PUT'
        handler.path = WaterButlerPath('/file')
        handler._send_hook = mock.Mock()

        assert handler.on_finish() is None
        handler._send_hook.assert_called_once_with('update')
Esempio n. 6
0
    async def test_on_finish_delete(self, handler):
        handler.request.method = 'DELETE'
        handler.target_path = WaterButlerPath('/file')
        handler._send_hook = mock.Mock()

        assert handler.on_finish() is None
        handler._send_hook.assert_called_once_with('delete')
Esempio n. 7
0
    async def test_on_finish_update(self, handler):
        handler.request.method = 'PUT'
        handler.path = WaterButlerPath('/file')
        handler._send_hook = mock.Mock()

        assert handler.on_finish() is None
        handler._send_hook.assert_called_once_with('update')
Esempio n. 8
0
    async def test_dont_send_hook_for_revisions(self, handler):
        handler.request.query_arguments['revisions'] = ''
        handler.request.method = 'GET'
        handler._send_hook = mock.Mock()

        assert handler.on_finish() is None
        assert not handler._send_hook.called
Esempio n. 9
0
    async def test_dont_send_hook_on_folder_metadata(self, handler):
        handler.request.method = 'GET'
        handler.path = WaterButlerPath('/folder/')
        handler._send_hook = mock.Mock()

        assert handler.on_finish() is None
        assert not handler._send_hook.called
    async def test_dont_send_hook_for_revisions(self, handler):
        handler.request.query_arguments['revisions'] = ''
        handler.request.method = 'GET'
        handler._send_hook = mock.Mock()

        assert handler.on_finish() is None
        assert not handler._send_hook.called
Esempio n. 11
0
    async def test_dont_send_hook_for_method(self, handler, method):
        """Not all HTTP methods merit a callback."""

        handler.request.method = method
        handler._send_hook = mock.Mock()

        assert handler.on_finish() is None
        assert not handler._send_hook.called
Esempio n. 12
0
    async def test_on_finish_copy(self, handler):
        handler.request.method = 'POST'
        handler.body = b'{"action": "copy"}'
        handler.target_path = WaterButlerPath('/folder/')
        handler._send_hook = mock.Mock()

        assert handler.on_finish() is None
        handler._send_hook.assert_called_once_with('copy')
Esempio n. 13
0
    async def test_on_finish_create_folder(self, handler):
        handler.request.method = 'PUT'
        handler._status_code = 201
        handler.target_path = WaterButlerPath('/folder/')
        handler._send_hook = mock.Mock()

        assert handler.on_finish() is None
        handler._send_hook.assert_called_once_with('create_folder')
    async def test_on_finish_download_zip(self, handler):
        handler.request.method = 'GET'
        handler.request.query_arguments['zip'] = ''
        handler.path = WaterButlerPath('/folder/')
        handler._send_hook = mock.Mock()

        assert handler.on_finish() is None
        handler._send_hook.assert_called_once_with('download_zip')
Esempio n. 15
0
    async def test_on_finish_download_zip(self, handler):
        handler.request.method = 'GET'
        handler.request.query_arguments['zip'] = ''
        handler.path = WaterButlerPath('/folder/')
        handler._send_hook = mock.Mock()

        assert handler.on_finish() is None
        handler._send_hook.assert_called_once_with('download_zip')
    async def test_dont_send_hook_for_method(self, handler, method):
        """Not all HTTP methods merit a callback."""

        handler.request.method = method
        handler._send_hook = mock.Mock()

        assert handler.on_finish() is None
        assert not handler._send_hook.called
    async def test_on_finish_copy(self, handler):
        handler.request.method = 'POST'
        handler.body = b'{"action": "copy"}'
        handler.target_path = WaterButlerPath('/folder/')
        handler._send_hook = mock.Mock()

        assert handler.on_finish() is None
        handler._send_hook.assert_called_once_with('copy')
    async def test_on_finish_create_folder(self, handler):
        handler.request.method = 'PUT'
        handler._status_code = 201
        handler.target_path = WaterButlerPath('/folder/')
        handler._send_hook = mock.Mock()

        assert handler.on_finish() is None
        handler._send_hook.assert_called_once_with('create_folder')
    async def test_dont_send_hook_for_status(self, handler, status):
        """Callbacks are only called for successful, entirely complete respsonses.  See comments
        in `on_finish` for further explanation."""

        handler._status_code = status
        handler._send_hook = mock.Mock()

        assert handler.on_finish() is None
        assert not handler._send_hook.called
Esempio n. 20
0
    async def test_dont_send_hook_for_status(self, handler, status):
        """Callbacks are only called for successful, entirely complete respsonses.  See comments
        in `on_finish` for further explanation."""

        handler._status_code = status
        handler._send_hook = mock.Mock()

        assert handler.on_finish() is None
        assert not handler._send_hook.called
    async def test_logging_direct_partial_download_file(self, handler):
        """For now, make sure partial+direct download requests get logged.  Behaviour may be
        changed in the future."""

        handler.request.method = 'GET'
        handler.path = WaterButlerPath('/file')
        handler._status_code = 302
        handler.request.headers['Range'] = 'fake-range'
        handler._send_hook = mock.Mock()

        assert handler.on_finish() is None
        handler._send_hook.assert_called_once_with('download_file')
Esempio n. 22
0
    async def test_logging_direct_partial_download_file(self, handler):
        """For now, make sure partial+direct download requests get logged.  Behaviour may be
        changed in the future."""

        handler.request.method = 'GET'
        handler.path = WaterButlerPath('/file')
        handler._status_code = 302
        handler.request.headers['Range'] = 'fake-range'
        handler._send_hook = mock.Mock()

        assert handler.on_finish() is None
        handler._send_hook.assert_called_once_with('download_file')