Esempio n. 1
0
    def test_event_exported(self):
        """Method to test the actions associated with a notification about an event being successfully exported."""

        with self.app.test_request_context():
            request_url = 'https://localhost/some/path/image.png'
            response = get_event_exported_actions(request_url)
            expected_action = NotificationAction(subject='event-export',
                                                 link=request_url,
                                                 action_type='download')
            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)
Esempio n. 2
0
def send_notif_after_export(user, event_name, download_url=None, error_text=None):
    """send notification after event import"""
    if error_text:
        send_notification(
            user=user,
            title=NOTIFS[EVENT_EXPORT_FAIL]['title'].format(event_name=event_name),
            message=NOTIFS[EVENT_EXPORT_FAIL]['message'].format(
                error_text=error_text)
        )
    elif download_url:
        actions = get_event_exported_actions(download_url)
        send_notification(
            user=user,
            title=NOTIFS[EVENT_EXPORTED]['title'].format(event_name=event_name),
            message=NOTIFS[EVENT_EXPORTED]['message'].format(
                event_name=event_name, download_url=download_url),
            actions=actions
        )