Skip to content

Commit

Permalink
model: Fetch realm emoji using events
Browse files Browse the repository at this point in the history
Fetching emoji using events ensures that realm emoji updates are not missed.
Initial state of realm emoji is updated from initial_data.
Added key 'realm_emoji' to initial_data to fix key error while running pytest.
Added new tests for the handler of emoji update event.
  • Loading branch information
mkp6781 committed Nov 26, 2020
1 parent 193dedb commit b6e1a7d
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions tests/model/test_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -1887,3 +1887,35 @@ def test_process_realm_emoji_data(self, mocker, model,
fetched_custom_emojis = model.process_realm_emoji_data()

assert fetched_custom_emojis == custom_emojis

@pytest.mark.parametrize('response', [
({
"last_event_id": -1,
"msg": "",
"queue_id": "1517975029:0",
"realm_emoji": {
"100": {
"id": "100",
"name": "urwid",
"deactivated": True
},
"1": {
"id": "1",
"name": "green_tick",
"deactivated": False
}
},
"result": "success",
"zulip_feature_level": 2,
"zulip_version": "2.1.0"
})
])
def test__handle_update_emoji_event(self, mocker, model,
response):
model._handle_update_emoji_event(response)
# For an already active emoji which has been deactivated
with pytest.raises(KeyError):
model.active_emoji_data['urwid']
# For a newly created custom emoji.
new_added_emoji = model.active_emoji_data['green_tick']['code']
assert new_added_emoji == response['realm_emoji']['1']['id']

0 comments on commit b6e1a7d

Please sign in to comment.