def test_available_groups(session): session.add(Ticket( number='FOO-1000-0001', title='test', group='one', handler_code='FOO', handler_id='1', state='open' )) session.add(Ticket( number='BAR-1000-0001', title='test', group='two', handler_code='BAR', handler_id='2', state='open' )) collection = TicketCollection(session) assert collection.subset().count() == 2 assert collection.for_group('one').subset().count() == 1 assert collection.for_group('two').subset().count() == 1 assert collection.available_groups() == ('one', 'two') assert collection.for_group('one').available_groups() == ('one', 'two') assert collection.for_group('two').available_groups() == ('one', 'two') assert collection.available_groups('FOO') == ('one', ) assert collection.available_groups('BAR') == ('two', )
def test_handle_extra_options(session, handlers): handlers.register('LTD', LimitingHandler) collection = TicketCollection(session) collection.handlers = handlers collection.open_ticket(handler_id='1', handler_code='LTD') collection.open_ticket(handler_id='2', handler_code='LTD') collection.open_ticket(handler_id='3', handler_code='LTD') assert collection.subset().count() == 3 collection.extra_parameters = {'limit': 1} assert collection.subset().count() == 3 collection.handler = 'LTD' assert collection.subset().count() == 1 collection.extra_parameters = {'limit': 2} assert collection.subset().count() == 2