Exemple #1
0
    def test_check_in_user(self):
        ticket_before = ticket_service.create_ticket(self.category_id, self.owner_id)

        ticket_before.used_by_id = self.user_id
        self.db.session.commit()

        assert not ticket_before.user_checked_in

        events_before = event_service.get_events_for_ticket(ticket_before.id)
        assert len(events_before) == 0

        # -------------------------------- #

        ticket_id = ticket_before.id

        ticket_service.check_in_user(ticket_id, self.orga_id)

        # -------------------------------- #

        ticket_after = ticket_service.find_ticket(ticket_id)
        assert ticket_before.user_checked_in

        events_after = event_service.get_events_for_ticket(ticket_after.id)
        assert len(events_after) == 1

        ticket_revoked_event = events_after[0]
        assert ticket_revoked_event.event_type == 'user-checked-in'
        assert ticket_revoked_event.data == {
            'checked_in_user_id': str(self.user_id),
            'initiator_id': str(self.orga_id),
        }
Exemple #2
0
    def test_revoke_ticket(self):
        ticket_before = ticket_service.create_ticket(self.category_id,
                                                     self.owner_id)
        assert not ticket_before.revoked

        events_before = event_service.get_events_for_ticket(ticket_before.id)
        assert len(events_before) == 0

        # -------------------------------- #

        ticket_id = ticket_before.id

        ticket_service.revoke_ticket(ticket_id)

        # -------------------------------- #

        ticket_after = ticket_service.find_ticket(ticket_id)
        assert ticket_after.revoked

        events_after = event_service.get_events_for_ticket(ticket_after.id)
        assert len(events_after) == 1

        ticket_revoked_event = events_after[0]
        assert ticket_revoked_event.event_type == 'ticket-revoked'
        assert ticket_revoked_event.data == {}
Exemple #3
0
    def test_check_in_user_with_ticket_user_already_checked_in(self):
        ticket = ticket_service.create_ticket(self.category_id, self.owner_id)

        ticket.used_by_id = self.user_id
        ticket.user_checked_in = True
        self.db.session.commit()

        with raises(UserAlreadyCheckIn):
            ticket_service.check_in_user(ticket.id, self.orga_id)
Exemple #4
0
    def test_check_in_user_with_revoked_ticket(self):
        ticket = ticket_service.create_ticket(self.category_id, self.owner_id)

        ticket.revoked = True
        ticket.used_by_id = self.user_id
        self.db.session.commit()

        with raises(TicketIsRevoked):
            ticket_service.check_in_user(ticket.id, self.orga_id)
Exemple #5
0
    def test_check_in_suspended_user(self):
        ticket = ticket_service.create_ticket(self.category_id, self.owner_id)

        ticket.used_by_id = self.user_id
        self.user.suspended = True
        self.db.session.commit()

        with raises(UserAccountSuspended):
            ticket_service.check_in_user(ticket.id, self.orga_id)
Exemple #6
0
    def setUp(self):
        super().setUp()

        self.user_number_sequence = count(1)

        self.owner = self.create_user('Ticket_Owner')

        self.category = self.create_category('Premium')

        self.ticket = ticket_service.create_ticket(self.category.id,
                                                   self.owner.id)
Exemple #7
0
    def setUp(self):
        super().setUp()

        self.owner = self.create_user('Ticket_Owner')

        self.create_brand_and_party()

        self.category_id = self.create_category('Premium').id

        self.ticket = ticket_service.create_ticket(self.category_id,
                                                   self.owner.id)