def test_edit_stream_rooms_diffent_mixed_admin_error(db, client, admin_jwt): stream = get_stream(db) room = MicrolocationSubVideoStreamFactory() db.session.commit() data = json.dumps({ 'data': { 'id': str(stream.id), 'type': 'video-stream', "relationships": { "rooms": { "data": [ { "id": str(room.id), "type": "microlocation" }, ] } }, } }) assert len(stream.rooms) == 1 response = client.patch( f'/v1/video-streams/{stream.id}', content_type='application/vnd.api+json', headers=admin_jwt, data=data, ) assert response.status_code == 403
def test_event_stream_rooms_no_access(db, client, jwt): event = EventFactoryBasic(state='published') MicrolocationSubVideoStreamFactory(event=event) db.session.commit() response = client.get(f'/v1/events/{event.id}/has-streams', headers=jwt) assert json.loads(response.data) == {"can_access": False, "exists": True}
def get_stream(db, user=None, **kwargs): stream = VideoStreamFactoryBase(**kwargs) room = MicrolocationSubVideoStreamFactory(video_stream=stream) if user: role, _ = get_or_create(Role, name='owner', title_name='Owner') UsersEventsRoles(user=user, event=room.event, role=role) db.session.commit() return stream
def test_event_stream_rooms(db, client, user, jwt): event = EventFactoryBasic(state='published') MicrolocationSubVideoStreamFactory(event=event) AttendeeOrderSubFactory(event=event, email=user.email, order__status='completed') db.session.commit() response = client.get(f'/v1/events/{event.id}/has-streams', headers=jwt) assert json.loads(response.data) == {"can_access": True, "exists": True}
def test_edit_stream_rooms_organizer(db, client, user, jwt): stream = get_stream(db, user=user) old_room = stream.rooms[0] room = MicrolocationSubVideoStreamFactory(event=old_room.event) db.session.commit() data = json.dumps({ 'data': { 'id': str(stream.id), 'type': 'video-stream', "relationships": { "rooms": { "data": [ { "id": str(room.id), "type": "microlocation" }, { "id": str(old_room.id), "type": "microlocation" }, ] } }, } }) assert len(stream.rooms) == 1 response = client.patch( f'/v1/video-streams/{stream.id}', content_type='application/vnd.api+json', headers=jwt, data=data, ) assert response.status_code == 200 db.session.refresh(stream) assert len(stream.rooms) == 2
def test_edit_stream_rooms_different_organizer_error(db, client, user, jwt): stream = get_stream(db, user=user) old_room = stream.rooms[0] room = MicrolocationSubVideoStreamFactory() db.session.commit() data = json.dumps({ 'data': { 'id': str(stream.id), 'type': 'video-stream', "relationships": { "rooms": { "data": [ { "id": str(room.id), "type": "microlocation" }, { "id": str(old_room.id), "type": "microlocation" }, ] } }, } }) assert len(stream.rooms) == 1 response = client.patch( f'/v1/video-streams/{stream.id}', content_type='application/vnd.api+json', headers=jwt, data=data, ) assert response.status_code == 403 assert ( json.loads(response.data)['errors'][0]['detail'] == 'Video Stream can only be created/edited with rooms of a single event')