コード例 #1
0
def send_notif_after_import(user, event_id=None, event_name=None, event_url=None, error_text=None):
    """send notification after event import"""
    if error_text:
        send_notification(
            user=user,
            title=NOTIFS[EVENT_IMPORT_FAIL]['title'],
            message=NOTIFS[EVENT_IMPORT_FAIL]['message'].format(
                error_text=error_text)
        )
    elif event_name:
        actions = get_event_imported_actions(event_id, event_url)
        send_notification(
            user=user,
            title=NOTIFS[EVENT_IMPORTED]['title'].format(event_name=event_name),
            message=NOTIFS[EVENT_IMPORTED]['message'].format(
                event_name=event_name, event_url=event_url),
            actions=actions
        )
コード例 #2
0
    def test_event_imported(self):
        """Method to test the actions associated with a notification about an event being successfully exported."""

        with app.test_request_context():
            request_url = 'https://localhost/e/345525'
            request_event_id = 1
            response = get_event_imported_actions(request_event_id, request_url)
            expected_action = NotificationAction(
                # subject is still 'event' since the action will be to view the imported event.
                subject='event',
                link=request_url,
                subject_id=request_event_id,
                action_type='view'
            )
            expected_action = [expected_action]
            expected_length = len(expected_action)
            response_length = len(response)
            self.assertIsInstance(response, list)
            self.assertEqual(expected_action[0].subject, response[0].subject)
            self.assertEqual(expected_length, response_length)