def test_clear_workspace_different_user(self, mock_messages, mock_redirect): mock_request = mock.MagicMock() mock_request.user.username = '******' clear_workspace(mock_request, 'ThisIsMe', 'url') mock_messages.assert_called_once_with(mock_request, "You are not allowed to change other users' settings.") mock_redirect.assert_called_once_with('user:profile', username=mock_request.user.username)
def test_clear_workspace_display(self, mock_render, mock_TethysApp, _): mock_request = mock.MagicMock() mock_request.user.username = '******' expected_context = {'app_name': mock_TethysApp.objects.get().name} clear_workspace(mock_request, 'ThisIsMe', 'root_url') mock_render.assert_called_once_with(mock_request, 'tethys_portal/user/clear_workspace.html', expected_context)
def test_clear_workspace_successful(self, mock_redirect, mock_message, mock_app, mock_user, mock_guw, mock_get_app_class): # noqa: E501 mock_request = mock.MagicMock(method='POST', POST='clear-workspace-submit') mock_request.user.username = '******' mock_user.objects.get.return_value = mock.MagicMock(User(username='******')) app = TethysApp(name='app_name') mock_app.objects.get.return_value = app mock_get_app_class.return_value = app app.pre_delete_user_workspace = mock.MagicMock() app.post_delete_user_workspace = mock.MagicMock() mock_guw.return_value = mock.MagicMock() clear_workspace(mock_request, 'ThisIsMe', 'root_url') mock_message.assert_called_once_with(mock_request, 'Your workspace has been successfully cleared.') mock_redirect.assert_called_once_with('user:manage_storage', username=mock_request.user.username)