Implement `__eq__` for CreateFolderParent class
@mwwoda がすでに取り組んでいます。
2024年12月16日 から。
評価
この issue はまだ評価されていません。
説明
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.
- 主要言語
- Python
- スター
- 460
- フォーク
- 223
- 平均マージ
- 14時間 18分
- マージ済み PR(30日)
- 21
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
box/box-python-sdk のほかの issue
-
enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
box/box-python-sdk#196 ·
-
bug enhancement
box/box-python-sdk#1314 · コメント 6 件 · 担当者 5 名 ·
-
enhancement
box/box-python-sdk#1154 · コメント 3 件 · 担当者 5 名 ·
-
enhancement
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
box/box-python-sdk#1155 · コメント 1 件 · リアクション 4 件 ·
-
dontstale enhancement question
box/box-python-sdk#1158 · コメント 1 件 · リアクション 1 件 · 担当者 6 名 ·
box/box-python-sdk の issue をすべて見る
似ている issue
-
documentation help wanted
難易度 2/5 1〜3時間 初心者へのやさしさ 90/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 90/100
simonw/sqlite-utils#872 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100