utils: improve group create or update #581
Annotations
12 errors
Tests / Tests (3.9, postgresql14, opensearch2):
tests/test_handlers_rest.py#L138
test_groups_handler[github]
assert 2 == 1
+ where 1 = len([<Role existing-group-id>])
|
Tests / Tests (3.9, postgresql14, opensearch2):
tests/test_handlers_rest.py#L138
test_groups_handler[orcid]
assert 2 == 1
+ where 1 = len([<Role existing-group-id>])
|
Tests / Tests (3.9, postgresql14, opensearch2):
tests/test_handlers_rest.py#L138
test_groups_handler[globus]
assert 2 == 1
+ where 1 = len([<Role existing-group-id>])
|
Tests / Tests (3.9, postgresql14, opensearch2):
tests/test_handlers_ui.py#L122
test_groups_handler
assert 2 == 1
+ where 1 = len([<Role existing-group-id>])
|
Tests / Tests (3.9, postgresql14, opensearch2):
invenio_oauthclient/handlers/utils.py#L1
Black format check
--- /home/runner/work/invenio-oauthclient/invenio-oauthclient/invenio_oauthclient/handlers/utils.py 2024-12-02 16:52:02.067458+00:00
+++ /home/runner/work/invenio-oauthclient/invenio-oauthclient/invenio_oauthclient/handlers/utils.py 2024-12-02 16:54:03.522467+00:00
@@ -113,18 +113,18 @@
roles_ids = set()
for group in groups:
try:
with db.session.begin_nested():
current_app.logger.debug(f"Syncing role: {group['name']}")
-
+
existing_role = current_datastore.find_role_by_id(group["id"])
if existing_role and existing_role.is_managed:
current_app.logger.exception(
f'Error while syncing roles: A managed role with id: {group["id"]} already exists'
)
continue
-
+
existing_role_by_name = current_datastore.find_role(group["name"])
if existing_role_by_name and existing_role_by_name.is_managed:
current_app.logger.exception(
f'Error while syncing roles: A managed role with name: {group["name"]} already exists'
)
@@ -147,11 +147,11 @@
)
role = current_datastore.update_role(role_to_update)
roles_ids.add(role.id)
else:
roles_ids.add(existing_role.id)
-
+
db.session.flush() # Ensure changes are written before committing
except Exception as e:
current_app.logger.error(
f"Error while syncing roles: {group['name']}. Error: {e}"
)
|
Tests / Tests (3.9, postgresql14, opensearch2)
Process completed with exit code 1.
|
Tests / Tests (3.12, postgresql14, opensearch2):
tests/test_handlers_rest.py#L138
test_groups_handler[github]
assert 2 == 1
+ where 1 = len([<Role existing-group-id>])
|
Tests / Tests (3.12, postgresql14, opensearch2):
tests/test_handlers_rest.py#L138
test_groups_handler[orcid]
assert 2 == 1
+ where 1 = len([<Role existing-group-id>])
|
Tests / Tests (3.12, postgresql14, opensearch2):
tests/test_handlers_rest.py#L138
test_groups_handler[globus]
assert 2 == 1
+ where 1 = len([<Role existing-group-id>])
|
Tests / Tests (3.12, postgresql14, opensearch2):
tests/test_handlers_ui.py#L122
test_groups_handler
assert 2 == 1
+ where 1 = len([<Role existing-group-id>])
|
Tests / Tests (3.12, postgresql14, opensearch2):
invenio_oauthclient/handlers/utils.py#L1
Black format check
--- /home/runner/work/invenio-oauthclient/invenio-oauthclient/invenio_oauthclient/handlers/utils.py 2024-12-02 16:52:02.779130+00:00
+++ /home/runner/work/invenio-oauthclient/invenio-oauthclient/invenio_oauthclient/handlers/utils.py 2024-12-02 16:54:19.829119+00:00
@@ -113,18 +113,18 @@
roles_ids = set()
for group in groups:
try:
with db.session.begin_nested():
current_app.logger.debug(f"Syncing role: {group['name']}")
-
+
existing_role = current_datastore.find_role_by_id(group["id"])
if existing_role and existing_role.is_managed:
current_app.logger.exception(
f'Error while syncing roles: A managed role with id: {group["id"]} already exists'
)
continue
-
+
existing_role_by_name = current_datastore.find_role(group["name"])
if existing_role_by_name and existing_role_by_name.is_managed:
current_app.logger.exception(
f'Error while syncing roles: A managed role with name: {group["name"]} already exists'
)
@@ -147,11 +147,11 @@
)
role = current_datastore.update_role(role_to_update)
roles_ids.add(role.id)
else:
roles_ids.add(existing_role.id)
-
+
db.session.flush() # Ensure changes are written before committing
except Exception as e:
current_app.logger.error(
f"Error while syncing roles: {group['name']}. Error: {e}"
)
|
Tests / Tests (3.12, postgresql14, opensearch2)
Process completed with exit code 1.
|