-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
stats: add missing import for StatsSearch
Co-Authored-by: Bertrand Zuchuat <[email protected]>
- Loading branch information
1 parent
e3622a0
commit c6809eb
Showing
2 changed files
with
62 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# -*- coding: utf-8 -*- | ||
# | ||
# RERO ILS | ||
# Copyright (C) 2023 RERO | ||
# Copyright (C) 2022 UCLouvain | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU Affero General Public License as published by | ||
# the Free Software Foundation, version 3 of the License. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU Affero General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU Affero General Public License | ||
# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
"""Stats views tests.""" | ||
|
||
from __future__ import absolute_import, print_function | ||
|
||
import mock | ||
from flask import url_for | ||
from invenio_accounts.testutils import login_user_via_session | ||
|
||
|
||
def test_view_status(client, patron_martigny, librarian_martigny): | ||
"""Test view status.""" | ||
# User not logged | ||
result = client.get(url_for('stats.stats_billing')) | ||
assert result.status_code == 401 | ||
|
||
# User without access permissions | ||
login_user_via_session(client, patron_martigny.user) | ||
result = client.get(url_for('stats.stats_billing')) | ||
assert result.status_code == 403 | ||
|
||
result = client.get(url_for('stats.live_stats_billing')) | ||
assert result.status_code == 403 | ||
|
||
# User with librarian permissions | ||
login_user_via_session(client, librarian_martigny.user) | ||
result = client.get(url_for('stats.stats_billing')) | ||
assert result.status_code == 403 | ||
|
||
result = client.get(url_for('stats.live_stats_billing')) | ||
assert result.status_code == 403 | ||
|
||
result = client.get(url_for('stats.stats_librarian')) | ||
assert result.status_code == 200 | ||
|
||
result = client.get(url_for('stats.stats_librarian', record_pid=1)) | ||
assert result.status_code == 200 | ||
|
||
with mock.patch( | ||
'rero_ils.modules.stats.permissions.admin_permission', | ||
mock.MagicMock() | ||
): | ||
result = client.get(url_for('stats.stats_billing')) | ||
assert result.status_code == 200 |