Implement `__eq__` for CreateFolderParent class
@mwwoda is already working on this.
Since Dec 16, 2024.
Assessment
This issue has not been assessed yet.
Description
Is your feature request related to a problem? Please describe.
I'm trying to use unittest to check call args:
def test_create_folder_exists(box: BoxClient):
with patch.object(box.folders, 'create_folder') as mock_create:
mock_create.side_effect = [
BoxAPIError(RequestInfo('POST', 'url', {}, {}), ResponseInfo(409, {}), '409'),
'FolderFull',
]
new_box.create_folder(
box,
PARENT_FOLDER_ID,
'test_folder_829',
increment=True,
)
assert mock_create.call_count == 2
mock_create.assert_any_call(
'test_folder_829 (1)',
CreateFolderParent(PARENT_FOLDER_ID), # THIS PART IS FAILING
)
(I'm trying to check that my code increments folder names on collisions, like name (1), name (2), etc.)
Unfortunately, the assertion does NOT pass, because CreateFolderParent doesn't implement __eq__:
In [9]: from box_sdk_gen import CreateFolderParent
In [10]: a = CreateFolderParent('12')
In [11]: b = CreateFolderParent('12')
In [12]: a == b
Out[12]: False
Describe the solution you'd like
Adding basic equality check makes my tests pass:
def __eq__(self, other):
if isinstance(other, CreateFolderParent):
return self.id == other.id
return False
I guess it would be nice to implement this for all these "arg" classes in the library, as there are lots of them.
Describe alternatives you've considered
I can fix my current issues with deep assert equal of the create_folder_parent.id values.
- Dominant language
- Python
- Stars
- 460
- Forks
- 223
- Avg merge
- 14h 18m
- Merged PRs (30d)
- 21
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from box/box-python-sdk
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
box/box-python-sdk#196 ·
-
bug enhancement
box/box-python-sdk#1314 · 6 comments · 5 assignees ·
-
enhancement
box/box-python-sdk#1154 · 3 comments · 5 assignees ·
-
enhancement
Difficulty 5/5 Over a week Newbie friendliness 25/100
box/box-python-sdk#1155 · 1 comment · 4 reactions ·
-
dontstale enhancement question
box/box-python-sdk#1158 · 1 comment · 1 reaction · 6 assignees ·
All issues in box/box-python-sdk
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100