def test_applyUpdates_and_setPrefix(self):
        registry = TestingRegistrationStack(a, b, c)
        request = TestRequest()
        view = ChangeRegistrations(registry, request)
        view.setPrefix("Pigs")

        # Make sure we don't apply updates unless asked to
        request.form = {'Pigs.active': 'disable'}
        view.applyUpdates()
        data = [(info['active'], info['registration'])
                for info in registry.info()]
        self.assertEqual(data, [(True, a), (False, b), (False, c)])

        # Now test disabling
        request.form = {'submit_update': '', 'Pigs.active': 'disable'}
        view.applyUpdates()
        data = [(info['active'], info['registration'])
                for info in registry.info()]
        self.assertEqual(data, [(False, a), (False, b), (False, c)])

        # Now test enabling c
        request.form = {'submit_update': '', 'Pigs.active': 'c'}
        view.applyUpdates()
        data = [(info['active'], info['registration'])
                for info in registry.info()]
        self.assertEqual(data, [(True, c), (False, a), (False, b)])
 def test___call__(self, IAdapter):
     from DateTime import DateTime
     from Products.ATContentTypes.interfaces.event import IATEvent
     request = TestRequest()
     adapter = getMultiAdapter((self.portal, request), ISearchEventResults)
     request.form = {'start': '2013-05-09'}
     IAdapter().portal_path.return_value = 'PORTAL_PATH'
     adapter(limit=2)
     IAdapter().get_content_listing.assert_called_with(IATEvent,
         end={'query': [DateTime('2013-05-09')], 'range': 'min'},
         b_size=10, sort_on='start', SearchableText='',
         start={'query': [None], 'range': 'max'}, sort_limit=2, b_start=0, path='PORTAL_PATH')