box / box/box-python-sdk

Implement `__eq__` for CreateFolderParent class

未关闭
#1,157 1 条评论 0 个 reaction 已指派 6 人 已被 @mwwoda 认领 在 GitHub 查看
enhancement
主要语言
Python
星标
459
派生
223
平均合并
8 小时 57 分钟
30 天内合并 PR
13

描述

### Is your feature request related to a problem? Please describe.

I'm trying to use unittest to check call args:

```python
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__`:

```ipython
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:

```python
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.

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。