From f1317172747486a943e752b44f09005f2feb63c8 Mon Sep 17 00:00:00 2001 From: Sara Han <127759186+sdiazlor@users.noreply.github.com> Date: Tue, 28 Nov 2023 17:44:34 +0100 Subject: [PATCH] bug: fix bug and update test (#4341) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit # Description Please include a summary of the changes and the related issue. Please also include relevant motivation and context. List any dependencies that are required for this change. Closes #4340 **Type of change** (Please delete options that are not relevant. Remember to title the PR according to the type of change) - [ ] Bug fix (non-breaking change which fixes an issue) - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) **How Has This Been Tested** (Please describe the tests that you ran to verify your changes. And ideally, reference `tests`) - [ ] Test A - [ ] Test B **Checklist** - [ ] I followed the style guidelines of this project - [ ] I did a self-review of my code - [ ] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] I filled out [the contributor form](https://tally.so/r/n9XrxK) (see text above) - [ ] I have added relevant notes to the `CHANGELOG.md` file (See https://keepachangelog.com/) --- src/argilla/client/feedback/utils/assignment.py | 4 ++-- tests/unit/client/feedback/utils/test_assignment.py | 11 +++++++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/argilla/client/feedback/utils/assignment.py b/src/argilla/client/feedback/utils/assignment.py index bb126eb9f0..c8ae428c49 100644 --- a/src/argilla/client/feedback/utils/assignment.py +++ b/src/argilla/client/feedback/utils/assignment.py @@ -241,7 +241,7 @@ def assign_workspaces( except: pass - wk_assignments[workspace_name] = [User.from_id(user).username for user in workspace.users] + wk_assignments[workspace_name] = [User.from_id(user.id).username for user in workspace.users] continue @@ -257,6 +257,6 @@ def assign_workspaces( except: pass - wk_assignments[workspace_name] = [User.from_id(user).username for user in workspace.users] + wk_assignments[workspace_name] = [User.from_id(user.id).username for user in workspace.users] return wk_assignments diff --git a/tests/unit/client/feedback/utils/test_assignment.py b/tests/unit/client/feedback/utils/test_assignment.py index 6c08171cc5..7db6a4af2a 100644 --- a/tests/unit/client/feedback/utils/test_assignment.py +++ b/tests/unit/client/feedback/utils/test_assignment.py @@ -57,9 +57,16 @@ def _factory(*args, **kwargs): mock = Mock(spec=Workspace) mock.users = [] + def create_mock_user(user_id): + user_mock = Mock() + user_mock.id = user_id + return user_mock + def add_user(user_id): - if user_id not in mock.users: - mock.users.append(user_id) + # Check if a user with this ID already exists in the list + if not any(user.id == user_id for user in mock.users): + mock_user = create_mock_user(user_id) + mock.users.append(mock_user) mock.add_user.side_effect = add_user