Skip to content

Commit

Permalink
Zoom: modify fixtures to use incremental IDs
Browse files Browse the repository at this point in the history
  • Loading branch information
pferreir committed Oct 15, 2024
1 parent f60f836 commit c772110
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
16 changes: 12 additions & 4 deletions vc_zoom/indico_vc_zoom/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
# them and/or modify them under the terms of the MIT License;
# see the LICENSE file for more details.

import itertools

import pytest

from indico.core.plugins import plugin_engine
from indico.modules.vc.models.vc_rooms import VCRoom, VCRoomEventAssociation, VCRoomLinkType, VCRoomStatus


@pytest.fixture
Expand Down Expand Up @@ -73,7 +74,6 @@ def _create(obj, link_type, zoom_name='Zoom Meeting', **kwargs):


JSON_DATA = {
'id': '12345abc',
'join_url': 'https://example.com/kitties',
'start_url': 'https://example.com/puppies',
'password': '13371337',
Expand All @@ -94,8 +94,13 @@ def _create(obj, link_type, zoom_name='Zoom Meeting', **kwargs):
@pytest.fixture
def zoom_api(zoom_plugin, create_user, mocker):
"""Mock some Zoom API endpoints."""
meeting_ids = iter(f'zmeeting{n}' for n in itertools.count(start=1, step=1))

def _create_meeting(*args, **kwargs):
return dict(JSON_DATA, id=next(meeting_ids))

api_create_meeting = mocker.patch('indico_vc_zoom.api.ZoomIndicoClient.create_meeting')
api_create_meeting.return_value = JSON_DATA
api_create_meeting.side_effect = _create_meeting

api_update_meeting = mocker.patch('indico_vc_zoom.api.ZoomIndicoClient.update_meeting')
api_update_meeting.return_value = {}
Expand All @@ -105,8 +110,11 @@ def zoom_api(zoom_plugin, create_user, mocker):
api_get_user = mocker.patch('indico_vc_zoom.api.ZoomIndicoClient.get_user')
api_get_user.return_value = {'id': '7890abcd', 'email': 'don.orange@megacorp.xyz'}

def _get_meeting(id_, *args, **kwargs):
return dict(JSON_DATA, id=id_)

api_get_meeting = mocker.patch('indico_vc_zoom.api.ZoomIndicoClient.get_meeting')
api_get_meeting.return_value = api_create_meeting.return_value
api_get_meeting.side_effect = _get_meeting

api_delete_meeting = mocker.patch('indico_vc_zoom.api.ZoomIndicoClient.delete_meeting')
api_delete_meeting.return_value = {}
Expand Down
2 changes: 1 addition & 1 deletion vc_zoom/tests/operation_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def _get_meeting(self, meeting_id):

zoom_plugin.update_room(vc_room, vc_room.events[0].event)

zoom_api['update_meeting'].assert_called_with('12345abc', {
zoom_api['update_meeting'].assert_called_with('zmeeting1', {
'password': '12341234',
})

Expand Down

0 comments on commit c772110

Please sign in to comment.