-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature-authorized-scopes-updater (#560)
* support Determinative type for transliteration * Implemented API for updating authorized_scopes of the fragment * Type check and reformatting * Type check fixed * Added test for authorized scopes * Refactorring * Adjusted tests * Fixed type check * Fixed Lint * Authorized scopes are included in Fragment Schema * Removed excluding of authorizedScopes in Fragment Schema * Reformatting * Fix provenance resource (#562) * adapt on_get to return provenance parents in square brackets * reformatting * Fixed test for provenance * Exclude restricted fragments from the latest addition list (#563) * Remove user scopes from latest addition aggregation Only include "open for all" fragments * add test_query_latest_skips_restricted_fragments * Correct AfO Register query * Correct format of AfO Register Query * Add Chicago numbers to Fragment (#564) * Add Aro Folios (#565) * remove push to old registry (#566) * genres add Qutāru (#567) * Update Scope format (#570) * update ScopeField * update function call * update test data * update match_user_scopes * Reformatting * add connection limit * Switch to ruff (#571) * install ruff * reformat files * fix mocking calls to user profile * suppress "Unable to concatenate tuple [60]" error * fix formatting error * refactor * update tasks * use ruff for linting and formatting * remove old config file * bugfix * add ruff * replace tuple() with () * remove C408 from ignored rules * replace `tuple()` with literal `()` and reformat * Adapted tests * Reformatting --------- Co-authored-by: fsimonjetz <[email protected]> Co-authored-by: Enrique Jiménez <[email protected]> Co-authored-by: Enrique Jiménez <[email protected]> Co-authored-by: zsomborfoldi <[email protected]> Co-authored-by: fsimonjetz <[email protected]>
- Loading branch information
1 parent
759e74c
commit b46c5ee
Showing
11 changed files
with
143 additions
and
5 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
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
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 |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import json | ||
|
||
import falcon | ||
import pytest | ||
|
||
from ebl.common.domain.scopes import Scope | ||
from ebl.schemas import ScopeField | ||
from ebl.fragmentarium.web.dtos import create_response_dto | ||
from ebl.tests.factories.fragment import FragmentFactory | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"parameters", | ||
[ | ||
{ | ||
"currentScopes": [], | ||
"newScopes": [Scope.READ_CAIC_FRAGMENTS], | ||
}, | ||
{ | ||
"currentScopes": [Scope.READ_CAIC_FRAGMENTS], | ||
"newScopes": [ | ||
Scope.READ_ITALIANNINEVEH_FRAGMENTS, | ||
Scope.READ_CAIC_FRAGMENTS, | ||
], | ||
}, | ||
{ | ||
"currentScopes": [Scope.READ_CAIC_FRAGMENTS], | ||
"newScopes": [], | ||
}, | ||
], | ||
) | ||
def test_update_scopes(client, fragmentarium, user, parameters): | ||
fragment = FragmentFactory.build(authorized_scopes=parameters["currentScopes"]) | ||
fragment_number = fragmentarium.create(fragment) | ||
updates = {"authorized_scopes": parameters["newScopes"]} | ||
json_updates = { | ||
"authorized_scopes": [ | ||
ScopeField()._serialize_enum(scope) | ||
for scope in parameters["newScopes"] | ||
if scope | ||
] | ||
} | ||
post_result = client.simulate_post( | ||
f"/fragments/{fragment_number}/scopes", body=json.dumps(json_updates) | ||
) | ||
expected_json = { | ||
**create_response_dto( | ||
fragment.set_scopes(updates["authorized_scopes"]), | ||
user, | ||
fragment.number == "K.1", | ||
) | ||
} | ||
assert post_result.status == falcon.HTTP_OK | ||
assert post_result.json == expected_json | ||
|
||
get_result = client.simulate_get(f"/fragments/{fragment_number}") | ||
assert get_result.json == expected_json |
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