コード例 #1
0
    def test_profile_quota(self, mock_get_user, mock_token_get_create, mock_render, mock_get_quota,
                           mock_convert_units, mock_has_mfa, _):
        mock_request = mock.MagicMock()
        username = '******'

        mock_context_user = mock.MagicMock()
        mock_get_user.return_value = mock_context_user

        mock_user_token = mock.MagicMock()
        mock_token_created = mock.MagicMock()
        mock_token_get_create.return_value = mock_user_token, mock_token_created
        mock_convert_units.return_value = '0 bytes'
        mock_get_quota.return_value = {'quota': 1, 'units': 0}
        mock_has_mfa.return_value = False

        expected_context = {
            'context_user': mock_context_user,
            'user_token': mock_user_token.key,
            'current_use': '0 bytes',
            'quota': '0 bytes',
            'has_mfa': False,
            'mfa_required': False,
            'show_user_token_mfa': True  # Show user token b/c mfa is not required
        }

        profile(mock_request, username)

        mock_render.assert_called_with(mock_request, 'tethys_portal/user/profile.html', expected_context)

        mock_get_user.assert_called_with(username='******')

        mock_token_get_create.assert_called_with(user=mock_context_user)
コード例 #2
0
ファイル: test_user.py プロジェクト: Chirag19/tethys
    def test_profile(self, mock_get_user, mock_token_get_create, mock_render):
        mock_request = mock.MagicMock()
        username = '******'

        mock_context_user = mock.MagicMock()
        mock_get_user.return_value = mock_context_user

        mock_user_token = mock.MagicMock()
        mock_token_created = mock.MagicMock()
        mock_token_get_create.return_value = mock_user_token, mock_token_created

        expected_context = {
            'context_user': mock_context_user,
            'user_token': mock_user_token.key
        }

        profile(mock_request, username)

        mock_render.assert_called_once_with(mock_request,
                                            'tethys_portal/user/profile.html',
                                            expected_context)

        mock_get_user.assert_called_once_with(username='******')

        mock_token_get_create.assert_called_once_with(user=mock_context_user)
コード例 #3
0
ファイル: test_user.py プロジェクト: keshava/tethys
    def test_profile(self, mock_get_user, mock_token_get_create, mock_render, mock_get_quota, mock_convert_units,
                     mock_settings, _):
        mock_request = mock.MagicMock()
        username = '******'

        mock_context_user = mock.MagicMock()
        mock_get_user.return_value = mock_context_user

        mock_user_token = mock.MagicMock()
        mock_token_created = mock.MagicMock()
        mock_token_get_create.return_value = mock_user_token, mock_token_created
        mock_convert_units.return_value = '0 bytes'
        mock_get_quota.return_value = {'quota': None}
        mock_settings.MFA_REQUIRED = False

        expected_context = {
            'context_user': mock_context_user,
            'user_token': mock_user_token.key,
            'current_use': '0 bytes',
            'quota': None,
            'has_mfa': False,
            'mfa_required': False
        }

        profile(mock_request, username)

        mock_render.assert_called_with(mock_request, 'tethys_portal/user/profile.html', expected_context)

        expected_context = {
            'context_user': mock_context_user,
            'user_token': mock_user_token.key,
            'current_use': '0 bytes',
            'quota': '0 bytes',
            'has_mfa': False,
            'mfa_required': False
        }

        mock_get_quota.return_value = {'quota': 1, 'units': 0}

        profile(mock_request, username)

        mock_render.assert_called_with(mock_request, 'tethys_portal/user/profile.html', expected_context)

        mock_get_user.assert_called_with(username='******')

        mock_token_get_create.assert_called_with(user=mock_context_user)