def test_module_search_error(self): from ptah.crowd.module import CrowdModuleView mod = self._make_mod() form = CrowdModuleView(mod, DummyRequest( POST=MultiDict({'form.buttons.search': 'Search'}))) form.csrf = False form.update() self.assertIn('Please specify search term', form.request.session['msgservice'][0])
def test_module_clear(self): from ptah.crowd.module import CrowdModuleView mod = self._make_mod() form = CrowdModuleView(mod, DummyRequest( session = {'ptah-search-term': 'test'}, POST=MultiDict({'form.buttons.clear': 'Clear'}))) form.csrf = False form.update() self.assertNotIn('ptah-search-term', form.request.session)
def test_module_search(self): from ptah.crowd.module import CrowdModuleView mod = self._make_mod() form = CrowdModuleView(mod, DummyRequest( POST=MultiDict({'form.buttons.search': 'Search', 'term': 'search term'}))) form.csrf = False try: form.update() except Exception, res: pass
def test_module_activate(self): from ptah.crowd.module import CrowdModuleView from ptah.crowd.provider import Session mod = self._make_mod() user = self._make_user() uri = user.uri props = ptah.crowd.get_properties(uri) props.suspended = True form = CrowdModuleView(mod, DummyRequest( POST=MultiDict( {'uid': uri, 'activate': 'activate'}))) form.csrf = False form.update() transaction.commit() self.assertIn('Selected accounts have been activated.', form.request.session['msgservice'][0]) props = ptah.crowd.get_properties(uri) self.assertFalse(props.suspended)