File tree Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Original file line number Diff line number Diff line change 22#
33# Copyright (C) 2019 CERN.
44# Copyright (C) 2019 Northwestern University.
5- # Copyright (C) 2023 Graz University of Technology
5+ # Copyright (C) 2023 Graz University of Technology.
6+ # Copyright (C) 2024 TU Wien.
67#
78# Invenio-Records-Permissions is free software; you can redistribute it
89# and/or modify it under the terms of the MIT License; see LICENSE file for
2223 AuthenticatedUser ,
2324 ConditionalGenerator ,
2425 Disable ,
26+ DisableIfReadOnly ,
2527 Generator ,
2628 IfConfig ,
2729 RecordOwners ,
@@ -266,3 +268,18 @@ def test_ifconfig(app, create_record):
266268 UserNeed (2 ),
267269 UserNeed (3 ),
268270 }
271+
272+
273+ def test_disable_if_read_only (app ):
274+ generator = DisableIfReadOnly ()
275+
276+ # Normal operation
277+ app .config ["RECORDS_PERMISSIONS_READ_ONLY" ] = False
278+ assert generator .excludes (record = None ) == set ()
279+ assert generator .query_filter (record = None ) == []
280+
281+ # System is in read-only mode
282+ app .config ["RECORDS_PERMISSIONS_READ_ONLY" ] = True
283+ assert generator .excludes (record = None ) == {any_user }
284+ query_filter = generator .query_filter (record = None )
285+ assert query_filter .to_dict () == {"match_none" : {}}
You can’t perform that action at this time.
0 commit comments