Skip to content

Commit

Permalink
refactor: ui: Patch *_box_views in OPEN_DRAFT tests.
Browse files Browse the repository at this point in the history
This commit assigns patches `stream_box_view` and `private_box_view`
using `mocker.patch.object` to maintain type consistency since their
mocked nature's assert methods are being called.
  • Loading branch information
prah23 authored and neiljp committed Jul 21, 2021
1 parent dbf7466 commit 295f69b
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions tests/ui/test_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,17 +361,21 @@ def test_keypress_OPEN_DRAFT(self, view, mocker, draft, key, widget_size):
"foo@zulip.com": {"user_id": 1},
"bar@gmail.com": {"user_id": 2},
}
mocked_stream_box_view = mocker.patch.object(view.write_box, "stream_box_view")
mocked_private_box_view = mocker.patch.object(
view.write_box, "private_box_view"
)

size = widget_size(view)
view.keypress(size, key)

if draft:
if draft["type"] == "stream":
view.write_box.stream_box_view.assert_called_once_with(
mocked_stream_box_view.assert_called_once_with(
caption=draft["to"], title=draft["subject"], stream_id=10
)
else:
view.write_box.private_box_view.assert_called_once_with(
mocked_private_box_view.assert_called_once_with(
emails=draft["to"], recipient_user_ids=[1, 2]
)

Expand Down

0 comments on commit 295f69b

Please sign in to comment.