Skip to content

[rel-DB] Complete presenter tests#3175

Merged
vkrasnovyd merged 9 commits intoOpenSlides:feature/relational-dbfrom
vkrasnovyd:rel-db-presenter-tests
Nov 18, 2025
Merged

[rel-DB] Complete presenter tests#3175
vkrasnovyd merged 9 commits intoOpenSlides:feature/relational-dbfrom
vkrasnovyd:rel-db-presenter-tests

Conversation

@vkrasnovyd
Copy link
Copy Markdown
Contributor

@vkrasnovyd vkrasnovyd commented Oct 10, 2025

Needs OpenSlides/openslides-meta#343 and #3174.

Most of the base test methods were moved from BaseActionTestCase to its parent BaseSystemTestCase to make them available to the presenter tests. Content of the base methods was not changed, but the order was updated, so these methods are now grouped by their purpose.

As discussed, checker related tests will be handled separately. Skipped them for now.

@vkrasnovyd vkrasnovyd marked this pull request as draft October 10, 2025 09:40
@vkrasnovyd vkrasnovyd force-pushed the rel-db-presenter-tests branch 2 times, most recently from 4e0dfa6 to 1ab27c3 Compare November 11, 2025 19:21
@vkrasnovyd vkrasnovyd force-pushed the rel-db-presenter-tests branch from 1ab27c3 to 0663850 Compare November 11, 2025 19:44
@vkrasnovyd vkrasnovyd marked this pull request as ready for review November 11, 2025 19:48
@vkrasnovyd vkrasnovyd requested a review from hjanott November 11, 2025 19:49
Copy link
Copy Markdown
Member

@hjanott hjanott left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here are my change requests. A lot of great improvements though.

Comment thread openslides_backend/presenter/get_forwarding_meetings.py Outdated
Comment thread tests/system/presenter/base.py Outdated
Comment thread tests/system/base.py Outdated
Comment thread tests/system/base.py Outdated
Comment on lines +691 to +707
def set_group_permissions(
self, group_id: int, permissions: list[Permission]
) -> None:
self.update_model(f"group/{group_id}", {"permissions": permissions})

def add_group_permissions(
self, group_id: int, permissions: list[Permission]
) -> None:
group = self.get_model(f"group/{group_id}")
self.set_group_permissions(group_id, group.get("permissions", []) + permissions)

def remove_group_permissions(
self, group_id: int, permissions: list[Permission]
) -> None:
group = self.get_model(f"group/{group_id}")
new_perms = [p for p in group.get("permissions", []) if p not in permissions]
self.set_group_permissions(group_id, new_perms)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please try instead of fetching, altering and pushing back to database to create manual events with:
[Event(type=EventType.Update, fqid=fqid, list_fields={"add": {}, "remove":{})]
You can see in the update_model how those events can be send to database.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fetching step is required for add_group_permissions and remove_group_permissions.

set_group_permissions (also used in the methods mentioned above) already creates events by calling update_model.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Solved with creating a helper method for generating list events. Also moved some duplicated logic from multiple methods into get_write_request and renamed it.

Comment thread tests/system/base.py
Comment thread tests/system/presenter/test_get_mediafile_context.py
Comment thread tests/system/presenter/test_get_user_related_models.py Outdated
Comment on lines +170 to +171
self.create_meeting_for_two_users(1, user_id, 111)
self.create_meeting_for_two_users(4, user_id, 111)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The variable user_id is nice and all but could be more descriptive (long: logged_in_user_id) and the other user ids (111, 777) could also be in a descriptive variable. I vote for doing it for this test. (fe.: logged_in_id, admin_id, unalterable_id)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using logged_in_user_id now.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replaced also the ids of the other 2 users and added a data assertion.

Comment thread tests/system/presenter/test_get_user_related_models.py
Comment on lines +41 to +48
"meeting_user/14": {"meeting_id": 1, "user_id": 4},
"meeting_user/16": {"meeting_id": 1, "user_id": 6},
"meeting_user/17": {"meeting_id": 1, "user_id": 7},
"meeting_user/47": {"meeting_id": 4, "user_id": 7},
"meeting_user/19": {"meeting_id": 1, "user_id": 9},
"meeting_user/49": {"meeting_id": 4, "user_id": 9},
"group/1": {"meeting_user_ids": [14, 16, 17, 19]},
"group/4": {"meeting_user_ids": [47, 49]},
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer set_user_groups.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or even extra parameters in create_user. Replaced.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. As discussed, updated create_user so it can also take committee_management_ids. Now user scope can be completely defined when calling this method.
  2. Updated usage of create_user in 2 user test cases to utilize this new setting.
  3. Checked the tests where the method is being currently used to make sure that the new variable does not break anything.

@vkrasnovyd vkrasnovyd requested a review from hjanott November 17, 2025 11:16
@vkrasnovyd vkrasnovyd assigned vkrasnovyd and unassigned hjanott Nov 18, 2025
@vkrasnovyd vkrasnovyd assigned hjanott and unassigned vkrasnovyd Nov 18, 2025
Copy link
Copy Markdown
Member

@hjanott hjanott left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lovely

@hjanott hjanott assigned vkrasnovyd and unassigned hjanott Nov 18, 2025
@vkrasnovyd vkrasnovyd merged commit c9311d8 into OpenSlides:feature/relational-db Nov 18, 2025
4 of 5 checks passed
@vkrasnovyd vkrasnovyd deleted the rel-db-presenter-tests branch November 18, 2025 15:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants