예제 #1
0
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_stream_get_attendee(db, client, user, jwt, order_status):
    room, stream, session = get_room_session_stream(db, name='Test Stream')
    email = '*****@*****.**'
    user._email = email
    AttendeeOrderSubFactory(event=room.event,
                            order__status=order_status,
                            email=email)
    db.session.commit()

    # Access by ID
    response = client.get(
        f'/v1/video-streams/{stream.id}',
        content_type='application/vnd.api+json',
        headers=jwt,
    )

    assert response.status_code == 200
    assert json.loads(response.data)['data']['id'] == str(stream.id)
    assert json.loads(
        response.data)['data']['attributes']['name'] == 'Test Stream'

    # Access by Room
    response = client.get(
        f'/v1/microlocations/{room.id}/video-stream',
        content_type='application/vnd.api+json',
        headers=jwt,
    )

    assert response.status_code == 200
    assert json.loads(
        response.data)['data']['attributes']['name'] == 'Test Stream'

    # Access by Room Include
    response = client.get(
        f'/v1/microlocations/{room.id}?include=video-stream',
        content_type='application/vnd.api+json',
        headers=jwt,
    )

    assert response.status_code == 200
    assert json.loads(
        response.data)['included'][0]['attributes']['name'] == 'Test Stream'

    # Access by Session Include
    response = client.get(
        f'/v1/sessions/{session.id}?include=microlocation.video-stream',
        content_type='application/vnd.api+json',
        headers=jwt,
    )

    assert response.status_code == 200
    assert json.loads(
        response.data)['included'][1]['attributes']['name'] == 'Test Stream'
def test_delete_ticket_holder_with_valid_order_id(db):
    """Method to test not deleting ticket holders with order id after expiry time"""

    attendee = AttendeeOrderSubFactory(
        created_at=datetime.datetime.utcnow() - datetime.timedelta(minutes=15),
        modified_at=datetime.datetime.utcnow() -
        datetime.timedelta(minutes=15),
    )
    db.session.commit()

    attendee_id = attendee.id
    delete_ticket_holders_no_order_id()
    ticket_holder = TicketHolder.query.get(attendee_id)
    assert ticket_holder != None
def test_delete_stream_user_accessible_error(db, client, user, jwt):
    stream = get_stream(db)
    email = '*****@*****.**'
    user._email = email
    AttendeeOrderSubFactory(event=stream.rooms[0].event,
                            order__status='completed',
                            email=email)
    db.session.commit()

    response = client.delete(
        f'/v1/video-streams/{stream.id}',
        content_type='application/vnd.api+json',
        headers=jwt,
    )

    assert response.status_code == 403
    assert (json.loads(response.data)['errors'][0]['detail'] ==
            "You don't have access to the event of provided rooms")
예제 #5
0
def test_notify_ticket_purchase_atttendee(db):
    order = OrderSubFactory(user=UserFactory())
    attendee = AttendeeOrderSubFactory(order=order, email='*****@*****.**')
    UserFactory(_email='*****@*****.**')
    db.session.commit()

    notify_ticket_purchase_attendee(order)
    notifications = Notification.query.order_by(Notification.id).all()

    notification_buyer = notifications[0]
    assert notification_buyer.user == order.user
    assert notification_buyer.content.type == NotificationType.TICKET_PURCHASED
    assert notification_buyer.content.target == order
    assert notification_buyer.content.actors[0].actor == order.user

    notification = notifications[1]
    assert notification.user == attendee.user
    assert notification.content.type == NotificationType.TICKET_PURCHASED_ATTENDEE
    assert notification.content.target == order
    assert notification.content.actors[0].actor == order.user