-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Report info/generation share collection selection function.
- Loading branch information
Showing
3 changed files
with
91 additions
and
48 deletions.
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
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 |
---|---|---|
|
@@ -10,6 +10,8 @@ | |
InventoryReportInfo, | ||
) | ||
from palace.manager.api.admin.problem_details import ADMIN_NOT_AUTHORIZED | ||
from palace.manager.api.overdrive import OverdriveAPI | ||
from palace.manager.core.opds_import import OPDSAPI | ||
from palace.manager.sqlalchemy.model.admin import Admin, AdminRole | ||
from palace.manager.sqlalchemy.util import create | ||
from palace.manager.util.problem_detail import ProblemDetailException | ||
|
@@ -77,7 +79,10 @@ def test_inventory_report_info( | |
email="[email protected]", role=AdminRole.LIBRARIAN, library=library1 | ||
) | ||
|
||
collection = db.collection() | ||
collection = db.collection( | ||
protocol=OPDSAPI.label(), | ||
settings={"data_source": "test", "external_account_id": "http://url"}, | ||
) | ||
collection.libraries = [library1, library2] | ||
|
||
success_payload_dict = InventoryReportInfo( | ||
|
@@ -124,27 +129,56 @@ def test_inventory_report_info( | |
assert admin_response_none.status_code == 404 | ||
|
||
@pytest.mark.parametrize( | ||
"settings, expect_collection", | ||
"protocol, settings, expect_collection", | ||
( | ||
({}, True), | ||
({"include_in_inventory_report": False}, False), | ||
({"include_in_inventory_report": True}, True), | ||
( | ||
OPDSAPI.label(), | ||
{"data_source": "test", "external_account_id": "http://url"}, | ||
True, | ||
), | ||
( | ||
OPDSAPI.label(), | ||
{ | ||
"include_in_inventory_report": False, | ||
"data_source": "test", | ||
"external_account_id": "http://test.url", | ||
}, | ||
False, | ||
), | ||
( | ||
OPDSAPI.label(), | ||
{ | ||
"include_in_inventory_report": True, | ||
"data_source": "test", | ||
"external_account_id": "http://test.url", | ||
}, | ||
True, | ||
), | ||
( | ||
OverdriveAPI.label(), | ||
{ | ||
"overdrive_website_id": "test", | ||
"overdrive_client_key": "test", | ||
"overdrive_client_secret": "test", | ||
}, | ||
False, | ||
), | ||
), | ||
) | ||
def test_inventory_report_info_reportable_collections( | ||
self, | ||
db: DatabaseTransactionFixture, | ||
flask_app_fixture: FlaskAppFixture, | ||
protocol: str, | ||
settings: dict, | ||
expect_collection: bool, | ||
): | ||
controller = ReportController(db.session) | ||
sysadmin = flask_app_fixture.admin_user(role=AdminRole.SYSTEM_ADMIN) | ||
|
||
library = db.library() | ||
collection = db.collection() | ||
collection = db.collection(protocol=protocol, settings=settings) | ||
collection.libraries = [library] | ||
collection._set_settings(**settings) | ||
|
||
expected_collections = ( | ||
[InventoryReportCollectionInfo(id=collection.id, name=collection.name)] | ||
|
@@ -157,7 +191,6 @@ def test_inventory_report_info_reportable_collections( | |
).api_dict() | ||
assert len(expected_collections) == expected_collection_count | ||
|
||
# Sysadmin can get info for any library. | ||
with flask_app_fixture.test_request_context( | ||
"/", admin=sysadmin, library=library | ||
): | ||
|