示例#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
示例#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()
示例#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()
示例#4
0
文件: worker.py 项目: wayne9qiu/aleph
    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()
示例#5
0
文件: worker.py 项目: moreymat/aleph
    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()
示例#6
0
def daily():
    generate_digest()
示例#7
0
文件: scheduled.py 项目: pudo/aleph
def daily():
    check_alerts()
    generate_digest()
示例#8
0
def daily_tasks():
    log.info("Running daily tasks...")
    check_alerts()
    generate_digest()