def test_notifications_center(self): try: view = api.portal.get().unrestrictedTraverse( "notifications_center") log("browser/notifications_center", "View exists.") except Exception: view = None log("browser/notifications_center", "Problems related to view.") self.assertTrue("SimpleViewClass" in str(view)) self.assertTrue("/templates/notifications_center" in str(view))
def test_catalogtool_search_users_by_preferences(self): from eea.notifications.catalogtool import get_catalog events = ['modified_custom', 'deleted_custom'] events_no = ['event 1', 'event 2'] catalog = get_catalog() catalog.set_events(user_id=TEST_USER_ID, events=events) tags = ['subject 1', 'subject 2'] tags_no = ['other 1', 'other 2'] catalog.set_tags(user_id=TEST_USER_ID, tags=tags) users = catalog.search_users_by_preferences( events=events, tags=tags, mode="or") self.assertTrue(TEST_USER_ID in users) if TEST_USER_ID in users: log("catalogtool", "User found by preferences as expected.") else: log("catalogtool", "User not found by preferences.", "error") users = catalog.search_users_by_preferences( events=events_no, tags=tags_no, mode="or") self.assertTrue(TEST_USER_ID not in users) if TEST_USER_ID not in users: log("catalogtool", "Search results seems ok.") else: log("catalogtool", "Wrong search results.", "error")
def test_catalogtool(self): from eea.notifications.catalogtool import get_catalog try: catalog = get_catalog() catalog = catalog # happy PEP exists = True except Exception: exists = False if exists: log("catalogtool", "Custom catalog exists.") self.assertTrue(exists) else: log("catalogtool", "Custom catalog is missing.", "error") self.assertTrue(exists)
def test_pingrmq(self): try: from eea.notifications.actions.pingrmq import PingRMQAction from eea.notifications.actions.pingrmq import PingRMQActionExecutor from eea.notifications.actions.pingrmq import PingRMQAddForm from eea.notifications.actions.pingrmq import PingRMQEditForm log("actions/pingrmq", "Related items are defined.") except Exception: PingRMQAction = None PingRMQActionExecutor = None PingRMQAddForm = None PingRMQEditForm = None log("actions/pingrmq", "Related items are missing", "error") self.assertTrue(PingRMQAction is not None) self.assertTrue(PingRMQActionExecutor is not None) self.assertTrue(PingRMQAddForm is not None) self.assertTrue(PingRMQEditForm is not None)
def test_indexers(self): try: from eea.notifications.content.indexers import getTags log("content/indexers", "getTags is defined.") except Exception: getTags = None log("content/indexers", "getTags is missing.", "error") self.assertTrue(getTags is not None) try: from eea.notifications.content.indexers import getUserTags log("content/indexers", "getUserTags is defined.") except Exception: getUserTags = None log("content/indexers", "getUserTags is missing.", "error") self.assertTrue(getUserTags is not None)
def test_events(self): try: from eea.notifications.actions.events import \ add_or_update_in_catalog from eea.notifications.actions.events import remove_from_catalog from eea.notifications.actions.events import object_modified from eea.notifications.actions.events import object_moved from eea.notifications.actions.events import object_added from eea.notifications.actions.events import object_removed log("actions/events", "Events defined.") except Exception: add_or_update_in_catalog = None remove_from_catalog = None object_modified = None object_moved = None object_added = None object_removed = None log("actions/events", "Events missing.", "error") self.assertTrue(add_or_update_in_catalog is not None) self.assertTrue(remove_from_catalog is not None) self.assertTrue(object_modified is not None) self.assertTrue(object_moved is not None) self.assertTrue(object_added is not None) self.assertTrue(object_removed is not None)
def test_catalogtool_tags_in_user_preferences(self): from eea.notifications.catalogtool import get_catalog # Try with a single tag tag = "a subject I like" tag_no = "not important" catalog = get_catalog() catalog.set_tags(user_id=TEST_USER_ID, tags=[tag]) selected = catalog.selected_tags(user_id=TEST_USER_ID) if (tag in selected) and (tag_no not in selected): log("catalogtool", "Set tags and get user selected ones is working.") else: log("catalogtool", "Set tags and get user selected ones is not working.", "error") self.assertTrue(tag in selected) self.assertTrue(tag_no not in selected) # Try with multiple tags tags = ['subject 1', 'subject 2'] tags_no = ['other 1', 'other 2'] catalog.set_tags(user_id=TEST_USER_ID, tags=tags) selected = catalog.selected_tags(user_id=TEST_USER_ID) ok = True for tag in tags: if tag not in selected: ok = False self.assertTrue(tag in selected) if ok: log("catalogtool", "Set multiple tags and get user selected ones is working.") else: log("catalogtool", "Set multiple tags and get user selected ones not working.", "error") ok = True for tag_no in tags_no: if tag_no in selected: ok = False self.assertTrue(tag_no not in selected) if ok: log("catalogtool", "Only set tags are present.") else: log("catalogtool", "Wrong behaviour setting tags.", "error")
def test_catalogtool_events_in_user_preferences(self): from eea.notifications.catalogtool import get_catalog # Try with a single event event = "something happened with this content" event_no = "something else happened" catalog = get_catalog() catalog.set_events(user_id=TEST_USER_ID, events=[event]) selected = catalog.selected_events(user_id=TEST_USER_ID) if (event in selected) and (event_no not in selected): log("catalogtool", "Set events and get user selected ones is working.") else: log("catalogtool", "Set events and get user selected ones is not working.", "error") self.assertTrue(event in selected) self.assertTrue(event_no not in selected) # Try with multiple events events = ['edited_custom', 'deleted_custom'] events_no = ['other_edited_custom', 'other_deleted_custom'] catalog.set_events(user_id=TEST_USER_ID, events=events) selected = catalog.selected_events(user_id=TEST_USER_ID) ok = True for event in events: if event not in selected: ok = False self.assertTrue(event in selected) if ok: log("catalogtool", "Set multiple events and get user selected ones is working.") else: log("catalogtool", "Set multiple events and get user selected ones not working.", "error") ok = True for event_no in events_no: if event_no in selected: ok = False self.assertTrue(event_no not in selected) if ok: log("catalogtool", "Only set events are present.") else: log("catalogtool", "Wrong behaviour setting events.", "error")
def test_catalogtool(self): log("catalogtool", "get_catalog function is defined.") from eea.notifications.catalogtool import get_catalog self.assertTrue('function' in str(type(get_catalog)))
def test_utils(self): try: from eea.notifications.utils import LOGGER log("utils", "LOGGER is defined.") except Exception: LOGGER = None log("utils", "LOGGER is missing.", "error") self.assertTrue(LOGGER is not None) try: from eea.notifications.utils import list_content_types log("utils", "list_content_types is defined.") except Exception: list_content_types = None log("utils", "list_content_types is missing.", "error") self.assertTrue(list_content_types is not None) try: from eea.notifications.utils import get_tags log("utils", "get_tags is defined.") except Exception: get_tags = None log("utils", "get_tags is missing.", "error") self.assertTrue(get_tags is not None) try: from eea.notifications.utils import get_rabbit_config log("utils", "get_rabbit_config is defined.") except Exception: get_rabbit_config = None log("utils", "get_rabbit_config is missing.", "error") self.assertTrue(get_rabbit_config is not None)
def test_notifications_center(self): try: from eea.notifications.browser.notifications_center import \ get_plone_site log("browser/notifications_center", "get_plone_site is defined.") except Exception: get_plone_site = None log("browser/notifications_center", "get_plone_site is missing.", "error") self.assertTrue(get_plone_site is not None) try: from eea.notifications.browser.notifications_center import \ notifications_center_operations as nco log("browser/notifications_center", "notifications_center_operations is defined.") except Exception: nco = None log("browser/notifications_center", "notifications_center_operations is missing.", "error") self.assertTrue(nco is not None) try: from eea.notifications.browser.notifications_center import \ notifications_center as nc log("browser/notifications_center", "notifications_center is defined.") except Exception: nc = None log("browser/notifications_center", "notifications_center is missing.", "error") self.assertTrue(nc is not None) try: from eea.notifications.browser.notifications_center import \ NotificationsCenter as nc log("browser/notifications_center", "NotificationsCenter is defined.") except Exception: nc = None log("browser/notifications_center", "NotificationsCenter is missing.", "error") self.assertTrue(nc is not None)
def test_interfaces(self): try: from eea.notifications.interfaces import \ IEEANotificationsCatalogTool log("interfaces", "IEEANotificationsCatalogTool is defined.") except Exception: IEEANotificationsCatalogTool = None log("interfaces", "IEEANotificationsCatalogTool is missing.", "error") self.assertTrue(IEEANotificationsCatalogTool is not None) try: from eea.notifications.interfaces import IEEANotificationsInstalled log("interfaces", "IEEANotificationsInstalled is defined.") except Exception: IEEANotificationsInstalled = None log("interfaces", "IEEANotificationsInstalled is missing.", "error") self.assertTrue(IEEANotificationsInstalled is not None) try: from eea.notifications.interfaces import IPingRMQAction log("interfaces", "IPingRMQAction is defined.") except Exception: IPingRMQAction = None log("interfaces", "IPingRMQAction is missing.", "error") self.assertTrue(IPingRMQAction is not None)