diff --git a/vc_zoom/indico_vc_zoom/fixtures.py b/vc_zoom/indico_vc_zoom/fixtures.py index b36d3e0d..075c215e 100644 --- a/vc_zoom/indico_vc_zoom/fixtures.py +++ b/vc_zoom/indico_vc_zoom/fixtures.py @@ -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 @@ -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', @@ -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 = {} @@ -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 = {} diff --git a/vc_zoom/tests/operation_test.py b/vc_zoom/tests/operation_test.py index f28e1b7e..b9257a39 100644 --- a/vc_zoom/tests/operation_test.py +++ b/vc_zoom/tests/operation_test.py @@ -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', })