예제 #1
0
    def setUp(self):
        super(FlaskMailNotificationTest, self).setUp()

        # Use flask-mail dependency
        self.flaskmail = FlaskMailConsumer.from_app(
            self.app, self.default_email_account, [self.default_email_account]
        )
예제 #2
0

# Add a new consumer to the user_hub
@user_hub.register_consumer(name="app.write_to_file")
def write_to_file(event, *args, **kwargs):
    with open("events.log", "a+w") as f:
        f.write(str(event))


# Register manually a push consumer
backend = notifications.create_backend()
push_consumer = PushConsumer(backend, user_hub_id)
user_hub.register_consumer(push_consumer)

# Create two independent email consumers
mail_consumer = FlaskMailConsumer.from_app(app, default_email_account,
                                           [default_email_account])

email_consumer = FlaskEmailConsumer.from_app(app, default_email_account,
                                             [default_email_account])

# Register one or more predefined consumers
for consumer in (mail_consumer, email_consumer):
    system_hub.register_consumer(consumer)

# Register filters for the hubs
now = datetime.now()

user_hub.filter_by(WithSender("john") | WithRecipients(["tom", "tim"]))

system_hub.filter_by(WithEventType("system") & Not(BeforeDate(now)))
예제 #3
0
# Add a new consumer to the user_hub
@user_hub.register_consumer(name="app.write_to_file")
def write_to_file(event, *args, **kwargs):
    with open("events.log", "a+w") as f:
        f.write(str(event))


# Register manually a push consumer
backend = notifications.create_backend()
push_consumer = PushConsumer(backend, user_hub_id)
user_hub.register_consumer(push_consumer)

# Create two independent email consumers
mail_consumer = FlaskMailConsumer.from_app(
    app, default_email_account, [default_email_account]
)

email_consumer = FlaskEmailConsumer.from_app(
    app, default_email_account, [default_email_account]
)

# Register one or more predefined consumers
for consumer in (mail_consumer, email_consumer):
    system_hub.register_consumer(consumer)

# Register filters for the hubs
now = datetime.now()

user_hub.filter_by(
    WithSender("john") | WithRecipients(["tom", "tim"])