def test_factory_menu_sorting(self): menu = FactoriesMenu(self.dossier) menu_items = menu.getMenuItems(self.dossier, self.dossier.REQUEST) self.assertEquals([ u'Document', 'document_with_template', u'Task', 'Add task from template', u'Subdossier', u'Participant' ], [item.get('title') for item in menu_items])
def test_mail_is_not_listed_in_factory_menu(self): self.login(self.dossier_responsible) menu = FactoriesMenu(self.dossier) menu_items = menu.getMenuItems(self.dossier, self.dossier.REQUEST) self.assertNotIn('ftw.mail.mail', [item.get('id') for item in menu_items])
def test_webactions_are_shown_at_end_of_factory_menu(self): self.login(self.administrator) for obj in self.contentish_objects: menu = FactoriesMenu(obj) webaction_menu_items = menu.getMenuItems(obj, self.dossier.REQUEST)[-2:] self.assertIn(u'\xc4ction 1', [item.get('title') for item in webaction_menu_items]) self.assertIn("Action 2", [item.get('title') for item in webaction_menu_items])
def test_mail_is_not_listed_in_factory_menu(self): self.login(self.dossier_responsible) menu = FactoriesMenu(self.dossier) menu_items = menu.getMenuItems( self.dossier, self.dossier.REQUEST) self.assertNotIn('ftw.mail.mail', [item.get('id') for item in menu_items])
def test_only_webactions_with_display_add_menu_are_shown_in_factory_menus(self): self.login(self.administrator) storage = get_storage() storage.update(1, {"display": "action-buttons"}) for obj in self.contentish_objects: menu = FactoriesMenu(obj) menu_items = menu.getMenuItems(obj, self.dossier.REQUEST) self.assertIn(u'\xc4ction 1', [item.get('title') for item in menu_items]) self.assertNotIn("Action 2", [item.get('title') for item in menu_items])
class TestFactoryMenu(FunctionalTestCase): def setUp(self): super(TestFactoryMenu, self).setUp() self.menu = FactoriesMenu(self.portal) create_client() set_current_client_id(self.portal) def test_task_menu_item_is_titled_task_in_a_dossier(self): dossier = create(Builder('dossier')) items = self.menu.getMenuItems(dossier, self.portal.REQUEST) task_action = [action for action in items if action.get('id') == 'opengever.task.task'][0] self.assertIn(u'Task', task_action.get('title')) def test_task_menu_item_is_titled_subtask_inside_a_task(self): task = create(Builder('task') .in_progress() .having(title='Task One', issuer=TEST_USER_ID, responsible=TEST_USER_ID)) items = self.menu.getMenuItems(task, self.portal.REQUEST) task_action = [action for action in items if action.get('id') == 'opengever.task.task'][0] self.assertIn(u'Subtask', task_action.get('title')) self.assertEquals(u'icon-task-subtask', task_action.get('extra').get('class')) def test_mail_menu_item_is_not_displayed_inside_a_task(self): task = create(Builder('task') .in_progress() .having(title='Task One', issuer=TEST_USER_ID, responsible=TEST_USER_ID)) self.assert_removed_menu_item('ftw.mail.mail', context=task) def assert_removed_menu_item(self, removed_item, context): factories_view = getMultiAdapter( (context, self.portal.REQUEST), name='folder_factories') factories_view.addable_types(include=None) all_items = [item.get('id') for item in factories_view.addable_types(include=None)] items = self.menu.getMenuItems(context, self.portal.REQUEST) filtered_items = [item.get('id') for item in items] self.assertEquals(set([removed_item,]), set(all_items)-set(filtered_items))
def test_factory_menu_sorting(self): menu = FactoriesMenu(self.dossier) menu_items = menu.getMenuItems(self.dossier, self.dossier.REQUEST) self.assertEquals( [u'Document', 'document_with_template', u'Task', 'Add task from template', u'Subdossier', u'Participant'], [item.get('title') for item in menu_items])
def test_factory_menu_enabled_for_businesscasedossier(self): dossier = create(Builder('dossier')) menu = FactoriesMenu(dossier) menu_items = menu.getMenuItems(dossier, dossier.REQUEST) self.assertEquals( ['Document', 'document_with_template', 'document_from_officeatwork', 'Task', 'Add task from template', 'Subdossier', 'Participant'], [item.get('title') for item in menu_items])
def test_factory_menu_sorting(self): menu = FactoriesMenu(self.dossier) menu_items = menu.getMenuItems(self.dossier, self.dossier.REQUEST) self.assertEquals( [ u"Document", "document_with_template", u"Task", "Add task from template", u"Subdossier", u"Participant", u"Proposal", ], [item.get("title") for item in menu_items], )
class TestFactoryMenu(FunctionalTestCase): def setUp(self): super(TestFactoryMenu, self).setUp() self.menu = FactoriesMenu(self.portal) create_client() set_current_client_id(self.portal) def test_task_menu_item_is_titled_task_in_a_dossier(self): dossier = create(Builder('dossier')) items = self.menu.getMenuItems(dossier, self.portal.REQUEST) task_action = [action for action in items if action.get('id') == 'opengever.task.task'][0] self.assertIn(u'Task', task_action.get('title')) def test_task_menu_item_is_titled_subtask_inside_a_task(self): task = create(Builder('task') .in_progress() .having(title='Task One', issuer=TEST_USER_ID, responsible=TEST_USER_ID)) items = self.menu.getMenuItems(task, self.portal.REQUEST) task_action = [action for action in items if action.get('id') == 'opengever.task.task'][0] self.assertIn(u'Subtask', task_action.get('title')) self.assertEquals(u'icon-task-subtask', task_action.get('extra').get('class')) def test_mail_menu_item_is_not_displayed_inside_a_task(self): task = create(Builder('task') .in_progress() .having(title='Task One', issuer=TEST_USER_ID, responsible=TEST_USER_ID)) factory_items = [item['id'] for item in self.menu.getMenuItems(task, self.portal.REQUEST)] self.assertNotIn('ftw.mail.mail', factory_items)
class TestFactoryMenu(FunctionalTestCase): def setUp(self): super(TestFactoryMenu, self).setUp() self.menu = FactoriesMenu(self.portal) def test_task_menu_item_is_titled_task_in_a_dossier(self): dossier = create(Builder('dossier')) items = self.menu.getMenuItems(dossier, self.portal.REQUEST) task_action = [ action for action in items if action.get('id') == 'opengever.task.task' ][0] self.assertIn(u'Task', task_action.get('title')) def test_task_menu_item_is_titled_subtask_inside_a_task(self): task = create( Builder('task').in_progress().having(title='Task One', issuer=TEST_USER_ID, responsible=TEST_USER_ID)) items = self.menu.getMenuItems(task, self.portal.REQUEST) task_action = [ action for action in items if action.get('id') == 'opengever.task.task' ][0] self.assertIn(u'Subtask', task_action.get('title')) self.assertEquals(u'icon-task-subtask', task_action.get('extra').get('class')) def test_mail_menu_item_is_not_displayed_inside_a_task(self): task = create( Builder('task').in_progress().having(title='Task One', issuer=TEST_USER_ID, responsible=TEST_USER_ID)) factory_items = [ item['id'] for item in self.menu.getMenuItems(task, self.portal.REQUEST) ] self.assertNotIn('ftw.mail.mail', factory_items)
def test_default_labels(self): """Check default form labels of subdossier We have a special handling of labels in subdossiers. We have different specialdossies, but we always have the same text in the add, edit and action-view. """ for dossier_type in self.dossier_types: d1 = self.create_dossier(dossier_type) # Check action label menu = FactoriesMenu(d1) menu_items = menu.getMenuItems(d1, d1.REQUEST) # mails should never be addable in a dossier (over the menu) self.assertTrue( 'ftw.mail.mail' not in [item.get('id') for item in menu_items]) # a dossier in a dossier should called subdossier self.assertIn( self.labels.get('action_name'), [item.get('title') for item in menu_items]) # Check title of addformular for a subdossier self.get_add_view( dossier_type, path=d1.absolute_url()) self.assertEquals( self.labels.get( 'add_subdossier') in self.browser.contents, True) url = self.browser.url.split('/')[-1] self.assertTrue(url == '++add++%s' % dossier_type) # Check edit label d2 = self.create_dossier(dossier_type, subpath=d1.getId()) self.get_edit_view(d2.absolute_url()) self.assertEquals( self.labels.get( 'edit_subdossier') in self.browser.contents, True)
def test_default_labels(self): """Check default form labels of subdossier We have a special handling of labels in subdossiers. We have different specialdossies, but we always have the same text in the add, edit and action-view. """ for dossier_type in self.dossier_types: d1 = self.create_dossier(dossier_type) # Check action label menu = FactoriesMenu(d1) menu_items = menu.getMenuItems(d1, d1.REQUEST) # mails should never be addable in a dossier (over the menu) self.assertTrue( 'ftw.mail.mail' not in [item.get('id') for item in menu_items]) # a dossier in a dossier should called subdossier self.assertIn(self.labels.get('action_name'), [item.get('title') for item in menu_items]) # Check title of addformular for a subdossier self.get_add_view(dossier_type, path=d1.absolute_url()) self.assertEquals( self.labels.get('add_subdossier') in self.browser.contents, True) url = self.browser.url.split('/')[-1] self.assertTrue(url == '++add++%s' % dossier_type) # Check edit label d2 = self.create_dossier(dossier_type, subpath=d1.getId()) self.get_edit_view(d2.absolute_url()) self.assertEquals( self.labels.get('edit_subdossier') in self.browser.contents, True)
def test_contentmenu_order_positions(self): """Check the order of the add-menu for dossiers and subdossiers """ for dossier_type in self.dossier_types: d1 = self.create_dossier(dossier_type) d2 = self.create_dossier(dossier_type, subpath=d1.getId()) # Check action label menu = FactoriesMenu(d1) menu2 = FactoriesMenu(d2) menu_items = menu.getMenuItems(d1, d1.REQUEST) menu_items2 = menu2.getMenuItems(d2, d2.REQUEST) # For dossiers for i, ordered_item in enumerate(self.default_contentmenu_order): menu_item_titles = [item['title'] for item in menu_items] # The item must be in the contentmenu self.assertTrue(ordered_item in menu_item_titles) # And must be in the correct position self.assertTrue(ordered_item == menu_item_titles[i]) # For subdossiers for i, ordered_item in enumerate( self.default_contentmenu_order_subdossier): menu_item_titles2 = [item['title'] for item in menu_items2] # The item must be in the contentmenu self.assertTrue(ordered_item in menu_item_titles2) # And must be in the correct position self.assertTrue(ordered_item == menu_item_titles2[i])
def setUp(self): super(TestFactoryMenu, self).setUp() self.menu = FactoriesMenu(self.portal) create_client() set_current_client_id(self.portal)
def get_factory_menu_items(self, obj): menu = FactoriesMenu(obj) return menu.getMenuItems(self.dossier, self.dossier.REQUEST)
def setUp(self): super(TestFactoryMenu, self).setUp() self.menu = FactoriesMenu(self.portal)