Beispiel #1
0
    def test_publish_event(self):
        role = self.create_user()
        email = '*****@*****.**'
        label = 'So public'
        recipient = self.create_user(foreign_id='rolex',
                                     email=email)
        update_role(recipient)
        collection = self.create_collection(foreign_id='NoNoNo', label=label)
        event = Events.PUBLISH_COLLECTION
        publish(event, role.id,
                params={'collection': collection},
                channels=[Notification.GLOBAL])
        db.session.commit()

        notifications = Notification.all().all()
        assert 1 == len(notifications), notifications
        not0 = notifications[0]
        assert not0._event == event.name, not0._event
        assert not0.params['collection'] == str(collection.id), not0.params

        with mail.record_messages() as outbox:
            assert len(outbox) == 0, outbox
            generate_digest()
            assert len(outbox) == 1, outbox
            msg = outbox[0]
            assert email in msg.recipients, msg.recipients
            assert label in msg.html, msg.html
Beispiel #2
0
    def periodic(self):
        db.session.remove()
        if self.hourly.check():
            self.hourly.update()
            log.info("Running hourly tasks...")
            index_collections()

        if self.daily.check():
            self.daily.update()
            log.info("Running daily tasks...")
            check_alerts()
            generate_digest()
Beispiel #3
0
    def periodic(self):
        db.session.remove()
        if self.hourly.check():
            self.hourly.update()
            log.info("Running hourly tasks...")
            self.cleanup_jobs()
            compute_collections()
            check_alerts()

        if self.daily.check():
            self.daily.update()
            log.info("Running daily tasks...")
            generate_digest()
            update_roles()
Beispiel #4
0
    def run_often(self):
        log.info("Self-check...")
        self.cleanup_jobs()
        compute_collections()

        if self.hourly.check():
            self.hourly.update()
            log.info("Running hourly tasks...")
            check_alerts()

        if self.daily.check():
            self.daily.update()
            log.info("Running daily tasks...")
            generate_digest()
            update_roles()
Beispiel #5
0
    def periodic(self):
        with app.app_context():
            db.session.remove()
            if self.often.check():
                self.often.update()
                log.info("Self-check...")
                self.cleanup_jobs()
                compute_collections()

            if self.daily.check():
                self.daily.update()
                log.info("Running daily tasks...")
                check_alerts()
                generate_digest()
                update_roles()
                delete_expired_exports()
Beispiel #6
0
def daily():
    generate_digest()
Beispiel #7
0
def daily():
    check_alerts()
    generate_digest()
Beispiel #8
0
def daily_tasks():
    log.info("Running daily tasks...")
    check_alerts()
    generate_digest()