feat: add room_id param to createRoom API (#7308)

* feat: add room_id param to createRoom API

* test: update tests_helpers.py
This commit is contained in:
Jennifer Richards 2024-04-09 13:21:35 -03:00 committed by GitHub
parent 279fb8565a
commit 2fb550ffce
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 26 additions and 15 deletions

View file

@ -1099,6 +1099,7 @@ def create_interim_session_conferences(sessions):
try: try:
confs = meetecho_manager.create( confs = meetecho_manager.create(
group=session.group, group=session.group,
session_id=session.pk,
description=str(session), description=str(session),
start_time=ts.utc_start_time(), start_time=ts.utc_start_time(),
duration=ts.duration, duration=ts.duration,

View file

@ -487,7 +487,7 @@ class InterimTests(TestCase):
mock.reset_mock() mock.reset_mock()
mock_conf_mgr.create.return_value = [ mock_conf_mgr.create.return_value = [
Conference( Conference(
manager=mock_conf_mgr, id=1, public_id='some-uuid', description='desc', manager=mock_conf_mgr, id=int(sessions[0].pk), public_id='some-uuid', description='desc',
start_time=timeslots[0].utc_start_time(), duration=timeslots[0].duration, url='fake-meetecho-url', start_time=timeslots[0].utc_start_time(), duration=timeslots[0].duration, url='fake-meetecho-url',
deletion_token='please-delete-me', deletion_token='please-delete-me',
), ),
@ -498,6 +498,7 @@ class InterimTests(TestCase):
mock_conf_mgr.create.call_args[1], mock_conf_mgr.create.call_args[1],
{ {
'group': sessions[0].group, 'group': sessions[0].group,
'session_id': sessions[0].id,
'description': str(sessions[0]), 'description': str(sessions[0]),
'start_time': timeslots[0].utc_start_time(), 'start_time': timeslots[0].utc_start_time(),
'duration': timeslots[0].duration, 'duration': timeslots[0].duration,
@ -512,12 +513,12 @@ class InterimTests(TestCase):
mock.reset_mock() mock.reset_mock()
mock_conf_mgr.create.side_effect = [ mock_conf_mgr.create.side_effect = [
[Conference( [Conference(
manager=mock_conf_mgr, id=1, public_id='some-uuid', description='desc', manager=mock_conf_mgr, id=int(sessions[0].pk), public_id='some-uuid', description='desc',
start_time=timeslots[0].utc_start_time(), duration=timeslots[0].duration, url='different-fake-meetecho-url', start_time=timeslots[0].utc_start_time(), duration=timeslots[0].duration, url='different-fake-meetecho-url',
deletion_token='please-delete-me', deletion_token='please-delete-me',
)], )],
[Conference( [Conference(
manager=mock_conf_mgr, id=2, public_id='another-uuid', description='desc', manager=mock_conf_mgr, id=int(sessions[1].pk), public_id='another-uuid', description='desc',
start_time=timeslots[1].utc_start_time(), duration=timeslots[1].duration, url='another-fake-meetecho-url', start_time=timeslots[1].utc_start_time(), duration=timeslots[1].duration, url='another-fake-meetecho-url',
deletion_token='please-delete-me-too', deletion_token='please-delete-me-too',
)], )],
@ -528,16 +529,18 @@ class InterimTests(TestCase):
mock_conf_mgr.create.call_args_list, mock_conf_mgr.create.call_args_list,
[ [
({ ({
'group': sessions[0].group, 'group': sessions[0].group,
'description': str(sessions[0]), 'session_id': sessions[0].id,
'start_time': timeslots[0].utc_start_time(), 'description': str(sessions[0]),
'duration': timeslots[0].duration, 'start_time': timeslots[0].utc_start_time(),
'duration': timeslots[0].duration,
},), },),
({ ({
'group': sessions[1].group, 'group': sessions[1].group,
'description': str(sessions[1]), 'session_id': sessions[1].id,
'start_time': timeslots[1].utc_start_time(), 'description': str(sessions[1]),
'duration': timeslots[1].duration, 'start_time': timeslots[1].utc_start_time(),
'duration': timeslots[1].duration,
},), },),
] ]
) )

View file

@ -115,6 +115,7 @@ class MeetechoAPI:
def schedule_meeting( def schedule_meeting(
self, self,
wg_token: str, wg_token: str,
room_id: int,
description: str, description: str,
start_time: datetime.datetime, start_time: datetime.datetime,
duration: datetime.timedelta, duration: datetime.timedelta,
@ -139,6 +140,7 @@ class MeetechoAPI:
} }
:param wg_token: token retrieved via retrieve_wg_tokens() :param wg_token: token retrieved via retrieve_wg_tokens()
:param room_id: int id to identify the room (will be echoed as room.id)
:param description: str describing the meeting :param description: str describing the meeting
:param start_time: starting time as a datetime :param start_time: starting time as a datetime
:param duration: duration as a timedelta :param duration: duration as a timedelta
@ -151,6 +153,7 @@ class MeetechoAPI:
"meeting/interim/createRoom", "meeting/interim/createRoom",
api_token=wg_token, api_token=wg_token,
json={ json={
"room_id": room_id,
"description": description, "description": description,
"start_time": self._serialize_time(start_time), "start_time": self._serialize_time(start_time),
"duration": self._serialize_duration(duration), "duration": self._serialize_duration(duration),
@ -455,9 +458,10 @@ class ConferenceManager(Manager):
response = self.api.fetch_meetings(self.wg_token(group)) response = self.api.fetch_meetings(self.wg_token(group))
return Conference.from_api_dict(self, response["rooms"]) return Conference.from_api_dict(self, response["rooms"])
def create(self, group, description, start_time, duration, extrainfo=""): def create(self, group, session_id, description, start_time, duration, extrainfo=""):
response = self.api.schedule_meeting( response = self.api.schedule_meeting(
wg_token=self.wg_token(group), wg_token=self.wg_token(group),
room_id=int(session_id),
description=description, description=description,
start_time=start_time, start_time=start_time,
duration=duration, duration=duration,

View file

@ -82,7 +82,7 @@ class APITests(TestCase):
'rooms': { 'rooms': {
'3d55bce0-535e-4ba8-bb8e-734911cf3c32': { '3d55bce0-535e-4ba8-bb8e-734911cf3c32': {
'room': { 'room': {
'id': 18, 'id': 18, # should match room_id in api.schedule_meeting() below
'start_time': '2021-09-14 10:00:00', 'start_time': '2021-09-14 10:00:00',
'duration': 130, 'duration': 130,
'description': 'interim-2021-wgname-01', 'description': 'interim-2021-wgname-01',
@ -97,6 +97,7 @@ class APITests(TestCase):
api = MeetechoAPI(API_BASE, CLIENT_ID, CLIENT_SECRET) api = MeetechoAPI(API_BASE, CLIENT_ID, CLIENT_SECRET)
api_response = api.schedule_meeting( api_response = api.schedule_meeting(
wg_token='my-token', wg_token='my-token',
room_id=18,
start_time=datetime.datetime(2021, 9, 14, 10, 0, 0, tzinfo=datetime.timezone.utc), start_time=datetime.datetime(2021, 9, 14, 10, 0, 0, tzinfo=datetime.timezone.utc),
duration=datetime.timedelta(minutes=130), duration=datetime.timedelta(minutes=130),
description='interim-2021-wgname-01', description='interim-2021-wgname-01',
@ -116,6 +117,7 @@ class APITests(TestCase):
self.assertEqual( self.assertEqual(
request.json(), request.json(),
{ {
'room_id': 18,
'duration': 130, 'duration': 130,
'start_time': '2021-09-14 10:00:00', 'start_time': '2021-09-14 10:00:00',
'extrainfo': 'message for staff', 'extrainfo': 'message for staff',
@ -485,7 +487,7 @@ class ConferenceManagerTests(TestCase):
'rooms': { 'rooms': {
'session-1-uuid': { 'session-1-uuid': {
'room': { 'room': {
'id': 1, 'id': 1, # value should match session_id param to cm.create() below
'start_time': datetime.datetime(2022,2,4,1,2,3, tzinfo=datetime.timezone.utc), 'start_time': datetime.datetime(2022,2,4,1,2,3, tzinfo=datetime.timezone.utc),
'duration': datetime.timedelta(minutes=45), 'duration': datetime.timedelta(minutes=45),
'description': 'some-description', 'description': 'some-description',
@ -496,7 +498,7 @@ class ConferenceManagerTests(TestCase):
}, },
} }
cm = ConferenceManager(settings.MEETECHO_API_CONFIG) cm = ConferenceManager(settings.MEETECHO_API_CONFIG)
result = cm.create('group', 'desc', 'starttime', 'dur', 'extra') result = cm.create('group', '1', 'desc', 'starttime', 'dur', 'extra')
self.assertEqual( self.assertEqual(
result, result,
[Conference( [Conference(
@ -515,6 +517,7 @@ class ConferenceManagerTests(TestCase):
kwargs, kwargs,
{ {
'wg_token': 'atoken', 'wg_token': 'atoken',
'room_id': 1,
'description': 'desc', 'description': 'desc',
'start_time': 'starttime', 'start_time': 'starttime',
'duration': 'dur', 'duration': 'dur',