Example #1
0
    def setUpClass(cls):
        with app.app_context():
            cls.common_data = dict(
                active=True,
                crontab="* * * * *",
                recipients=cls.RECIPIENTS,
                deliver_as_group=True,
                delivery_type=EmailDeliveryType.inline,
            )

            # Pick up a sample slice and dashboard
            slce = db.session.query(Slice).filter_by(
                slice_name="Participants").one()
            dashboard = (db.session.query(Dashboard).filter_by(
                dashboard_title="World Bank's Data").one())

            dashboard_schedule = DashboardEmailSchedule(**cls.common_data)
            dashboard_schedule.dashboard_id = dashboard.id
            dashboard_schedule.user_id = 1
            db.session.add(dashboard_schedule)

            slice_schedule = SliceEmailSchedule(**cls.common_data)
            slice_schedule.slice_id = slce.id
            slice_schedule.user_id = 1
            slice_schedule.email_format = SliceEmailReportFormat.data
            slice_schedule.slack_channel = "#test_channel"

            db.session.add(slice_schedule)
            db.session.commit()

            cls.slice_schedule = slice_schedule.id
            cls.dashboard_schedule = dashboard_schedule.id
Example #2
0
    def setUpClass(cls):
        cls.common_data = dict(
            active=True,
            crontab='* * * * *',
            recipients=cls.RECIPIENTS,
            deliver_as_group=True,
            delivery_type=EmailDeliveryType.inline,
        )

        # Pick up a random slice and dashboard
        slce = db.session.query(Slice).all()[0]
        dashboard = db.session.query(Dashboard).all()[0]

        dashboard_schedule = DashboardEmailSchedule(**cls.common_data)
        dashboard_schedule.dashboard_id = dashboard.id
        dashboard_schedule.user_id = 1
        db.session.add(dashboard_schedule)

        slice_schedule = SliceEmailSchedule(**cls.common_data)
        slice_schedule.slice_id = slce.id
        slice_schedule.user_id = 1
        slice_schedule.email_format = SliceEmailReportFormat.data

        db.session.add(slice_schedule)
        db.session.commit()

        cls.slice_schedule = slice_schedule.id
        cls.dashboard_schedule = dashboard_schedule.id
    def setUpClass(cls):
        with app.app_context():
            cls.common_data = dict(
                active=True,
                crontab="* * * * *",
                recipients=cls.RECIPIENTS,
                deliver_as_group=True,
                delivery_type=EmailDeliveryType.inline,
            )

            # Pick up a random slice and dashboard
            slce = db.session.query(Slice).all()[0]
            dashboard = db.session.query(Dashboard).all()[0]

            dashboard_schedule = DashboardEmailSchedule(**cls.common_data)
            dashboard_schedule.dashboard_id = dashboard.id
            dashboard_schedule.user_id = 1
            db.session.add(dashboard_schedule)

            slice_schedule = SliceEmailSchedule(**cls.common_data)
            slice_schedule.slice_id = slce.id
            slice_schedule.user_id = 1
            slice_schedule.email_format = SliceEmailReportFormat.data
            slice_schedule.slack_channel = "#test_channel"

            db.session.add(slice_schedule)
            db.session.commit()

            cls.slice_schedule = slice_schedule.id
            cls.dashboard_schedule = dashboard_schedule.id
    def add_schedule_slice_and_dashboard(self):
        with app.app_context():
            self.common_data = dict(
                active=True,
                crontab="* * * * *",
                recipients=self.RECIPIENTS,
                deliver_as_group=True,
                delivery_type=EmailDeliveryType.inline,
            )
            # Pick up a sample slice and dashboard
            slice = db.session.query(Slice).filter_by(slice_name="Region Filter").one()
            dashboard = (
                db.session.query(Dashboard)
                .filter_by(dashboard_title="World Bank's Data")
                .one()
            )

            dashboard_schedule = DashboardEmailSchedule(**self.common_data)
            dashboard_schedule.dashboard_id = dashboard.id
            dashboard_schedule.user_id = 1
            db.session.add(dashboard_schedule)

            slice_schedule = SliceEmailSchedule(**self.common_data)
            slice_schedule.slice_id = slice.id
            slice_schedule.user_id = 1
            slice_schedule.email_format = SliceEmailReportFormat.data
            slice_schedule.slack_channel = "#test_channel"

            db.session.add(slice_schedule)
            db.session.commit()

            self.slice_schedule = slice_schedule.id
            self.dashboard_schedule = dashboard_schedule.id

        yield

        with app.app_context():
            db.session.query(SliceEmailSchedule).filter_by(
                id=self.slice_schedule
            ).delete()
            db.session.query(DashboardEmailSchedule).filter_by(
                id=self.dashboard_schedule
            ).delete()
            db.session.commit()