示例#1
0
    def test_enabled_events(self):
        frappe.flags.enabled_events = [
            "hourly", "hourly_long", "daily", "daily_long", "weekly",
            "weekly_long", "monthly", "monthly_long"
        ]

        # maintain last_event and next_event on the same day
        last_event = now_datetime().replace(hour=0,
                                            minute=0,
                                            second=0,
                                            microsecond=0)
        next_event = last_event + relativedelta(minutes=30)

        enqueue_applicable_events(frappe.local.site, next_event, last_event)
        self.assertFalse("cron" in frappe.flags.ran_schedulers)

        # maintain last_event and next_event on the same day
        last_event = now_datetime().replace(hour=0,
                                            minute=0,
                                            second=0,
                                            microsecond=0)
        next_event = last_event + relativedelta(hours=2)

        enqueue_applicable_events(frappe.local.site, next_event, last_event)
        self.assertTrue("all" in frappe.flags.ran_schedulers)
        self.assertTrue("hourly" in frappe.flags.ran_schedulers)

        del frappe.flags['enabled_events']
    def test_enabled_events(self):
        val = json.dumps([
            "hourly", "hourly_long", "daily", "daily_long", "weekly",
            "weekly_long", "monthly", "monthly_long"
        ])
        frappe.db.set_global('enabled_scheduler_events', val)

        # maintain last_event and next_event on the same day
        last_event = now_datetime().replace(hour=0,
                                            minute=0,
                                            second=0,
                                            microsecond=0)
        next_event = last_event + relativedelta(minutes=30)

        enqueue_applicable_events(frappe.local.site, next_event, last_event)
        self.assertFalse("all" in frappe.flags.ran_schedulers)

        # maintain last_event and next_event on the same day
        last_event = now_datetime().replace(hour=0,
                                            minute=0,
                                            second=0,
                                            microsecond=0)
        next_event = last_event + relativedelta(hours=2)

        enqueue_applicable_events(frappe.local.site, next_event, last_event)
        self.assertTrue("all" in frappe.flags.ran_schedulers)
        self.assertTrue("hourly" in frappe.flags.ran_schedulers)

        frappe.db.set_global('enabled_scheduler_events', "")
示例#3
0
	def test_enabled_events_day_change(self):
		val = json.dumps(["daily", "daily_long", "weekly", "weekly_long", "monthly", "monthly_long"])
		frappe.db.set_global('enabled_scheduler_events', val)

		last = now_datetime() - relativedelta(days=2)

		enqueue_applicable_events(frappe.local.site, now_datetime(), last)
		self.assertTrue("all" in frappe.flags.ran_schedulers)
		self.assertTrue("hourly" in frappe.flags.ran_schedulers)
示例#4
0
	def test_enabled_events_day_change(self):
		val = json.dumps(["daily", "daily_long", "weekly", "weekly_long", "monthly", "monthly_long"])
		frappe.db.set_global('enabled_scheduler_events', val)

		# maintain last_event and next_event on different days
		next_event = now_datetime().replace(hour=0, minute=0, second=0, microsecond=0)
		last_event = next_event - relativedelta(hours=2)

		enqueue_applicable_events(frappe.local.site, next_event, last_event)
		self.assertTrue("all" in frappe.flags.ran_schedulers)
		self.assertTrue("hourly" in frappe.flags.ran_schedulers)
示例#5
0
	def test_enabled_events_day_change(self):

		# use flags instead of globals as this test fails intermittently
		# the root cause has not been identified but the culprit seems cache
		# since cache is mutable, it maybe be changed by a parallel process
		frappe.flags.enabled_events = ["daily", "daily_long", "weekly", "weekly_long",
			"monthly", "monthly_long"]

		# maintain last_event and next_event on different days
		next_event = now_datetime().replace(hour=0, minute=0, second=0, microsecond=0)
		last_event = next_event - relativedelta(hours=2)

		frappe.flags.ran_schedulers = []
		enqueue_applicable_events(frappe.local.site, next_event, last_event)
		self.assertTrue("all" in frappe.flags.ran_schedulers)
		self.assertFalse("hourly" in frappe.flags.ran_schedulers)

		frappe.flags.enabled_events = None
示例#6
0
	def test_enabled_events(self):
		frappe.flags.enabled_events = ["hourly", "hourly_long", "daily", "daily_long", "weekly", "weekly_long", "monthly", "monthly_long"]

		# maintain last_event and next_event on the same day
		last_event = now_datetime().replace(hour=0, minute=0, second=0, microsecond=0)
		next_event = last_event + relativedelta(minutes=30)

		enqueue_applicable_events(frappe.local.site, next_event, last_event)
		self.assertFalse("all" in frappe.flags.ran_schedulers)

		# maintain last_event and next_event on the same day
		last_event = now_datetime().replace(hour=0, minute=0, second=0, microsecond=0)
		next_event = last_event + relativedelta(hours=2)

		enqueue_applicable_events(frappe.local.site, next_event, last_event)
		self.assertTrue("all" in frappe.flags.ran_schedulers)
		self.assertTrue("hourly" in frappe.flags.ran_schedulers)

		del frappe.flags['enabled_events']
示例#7
0
	def test_all_events(self):
		last = now_datetime() - relativedelta(hours=2)
		enqueue_applicable_events(frappe.local.site, now_datetime(), last)
		self.assertTrue("all" in frappe.flags.ran_schedulers)