예제 #1
0
	def test_months_multiple_forward(self):
		hour, minute = Utils.get_time_now()
		entry = "{} {} * 6-8 * ls # SuperCron__TEST__ls".format(minute, hour).encode()
		args = Namespace(Utils.list_to_dict("TEST__ls", "ls", "from June to August"))
		SuperCron.add_job(args)
		user_crontab = Utils.get_crontab()
		self.assertTrue(entry in user_crontab)
예제 #2
0
	def test_months_multiple_backward(self):
		hour, minute = Utils.get_time_now()
		entry = "{} {} * 1,10,11,12 * ls # SuperCron__TEST__ls".format(minute, hour).encode()
		args = Namespace(Utils.list_to_dict("TEST__ls", "ls", "from October to January"))
		SuperCron.add_job(args)
		user_crontab = Utils.get_crontab()
		self.assertTrue(entry in user_crontab)
예제 #3
0
	def test_months_multiple_non_consecutive(self):
		hour, minute = Utils.get_time_now()
		entry = "{} {} * 2,5,9 * ls # SuperCron__TEST__ls".format(minute, hour).encode()
		args = Namespace(Utils.list_to_dict("TEST__ls", "ls", "in May and September and February"))
		SuperCron.add_job(args)
		user_crontab = Utils.get_crontab()
		self.assertTrue(entry in user_crontab)
예제 #4
0
	def test_months_single(self):
		hour, minute = Utils.get_time_now()
		entry = "{} {} * 5 * ls # SuperCron__TEST__ls".format(minute, hour).encode()
		args = Namespace(Utils.list_to_dict("TEST__ls", "ls", "in May"))
		SuperCron.add_job(args)
		user_crontab = Utils.get_crontab()
		self.assertTrue(entry in user_crontab)
예제 #5
0
	def test_weekdays_multiple_backward(self):
		hour, minute = Utils.get_time_now()
		entry = "{} {} * * 0,1,5,6 ls # SuperCron__TEST__ls".format(minute, hour).encode()
		args = Namespace(Utils.list_to_dict("TEST__ls", "ls", "from friday to monday"))
		SuperCron.add_job(args)
		user_crontab = Utils.get_crontab()
		self.assertTrue(entry in user_crontab)
예제 #6
0
	def test_short_months(self):
		hour, minute = Utils.get_time_now()
		entry = "{} {} * 1,10,11,12 * ls # SuperCron__TEST__ls".format(minute, hour).encode()
		args = Namespace(Utils.list_to_dict("TEST__ls", "ls", "from oct to jan"))
		SuperCron.add_job(args)
		user_crontab = Utils.get_crontab()
		self.assertTrue(entry in user_crontab)
예제 #7
0
	def test_mixed_month_weekday_every_x_hours(self):
		hour, minute = Utils.get_time_now()
		entry = "{} */4 * 4 6 ls # SuperCron__TEST__ls".format(minute).encode()
		args = Namespace(Utils.list_to_dict("TEST__ls", "ls", "every 4 hours on saturdays in april"))
		SuperCron.add_job(args)
		user_crontab = Utils.get_crontab()
		self.assertTrue(entry in user_crontab)
예제 #8
0
	def test_day_full_month(self):
		hour, minute = Utils.get_time_now()
		entry = "{} {} 14 3 * ls # SuperCron__TEST__ls".format(minute, hour).encode()
		args = Namespace(Utils.list_to_dict("TEST__ls", "ls", "14 march"))
		SuperCron.add_job(args)
		user_crontab = Utils.get_crontab()
		self.assertTrue(entry in user_crontab)
예제 #9
0
	def test_midnight(self):
		entry1 = b"@daily ls # SuperCron__TEST__ls"
		entry2  = b"0 0 * * * ls # SuperCron__TEST__ls"
		args = Namespace(Utils.list_to_dict("TEST__ls", "ls", "midnight"))
		SuperCron.add_job(args)
		user_crontab = Utils.get_crontab()
		self.assertTrue(entry1 in user_crontab or entry2 in user_crontab)
예제 #10
0
	def test_every_x_days(self):
		hour, minute = Utils.get_time_now()
		entry = "{} {} */11 * * ls # SuperCron__TEST__ls".format(minute, hour).encode()
		args = Namespace(Utils.list_to_dict("TEST__ls", "ls", "once every 11 days"))
		SuperCron.add_job(args)
		user_crontab = Utils.get_crontab()
		self.assertTrue(entry in user_crontab)
예제 #11
0
	def test_mixed_month_multiple_weekday_multiple_every_x_days_midnight(self):
		entry = b"0 0 */2 10,12 1-5 ls # SuperCron__TEST__ls"
		args = Namespace(Utils.list_to_dict("TEST__ls", "ls",
			"midnight every 2 days from monday to friday in october and december"))
		SuperCron.add_job(args)
		user_crontab = Utils.get_crontab()
		self.assertTrue(entry in user_crontab)
예제 #12
0
	def test_weekdays_multiple_non_consecutive(self):
		hour, minute = Utils.get_time_now()
		entry = "{} {} * * 1,3,5 ls # SuperCron__TEST__ls".format(minute, hour).encode()
		args = Namespace(Utils.list_to_dict("TEST__ls", "ls", "on mondays, wednesdays and fridays"))
		SuperCron.add_job(args)
		user_crontab = Utils.get_crontab()
		self.assertTrue(entry in user_crontab)
예제 #13
0
	def test_trigger_off_if_added(self):
		entry = b"# 11 11 * * * echo 1 > /dev/null # SuperCron__TEST__echo1%off:TEST__echo2:added"
		args1 = Namespace({"name": "TEST__echo2"})
		SuperCron.delete_job(args1)
		args2 = Namespace({"name": "TEST__echo1", "trigger": ["off if TEST__echo2 is added"]})
		SuperCron.trigger_job(args2)
		args1 = Namespace(Utils.list_to_dict("TEST__echo2", "echo 2 > /dev/null", "12:12"))
		SuperCron.add_job(args1)
		user_crontab = Utils.get_crontab()
		self.assertTrue(entry in user_crontab)
예제 #14
0
	def test_mixed_datetime(self):
		entry = b"8 0 1 6 * ls # SuperCron__TEST__ls"
		args = Namespace(Utils.list_to_dict("TEST__ls", "ls", "1/6 12:08 am"))
		SuperCron.add_job(args)
		user_crontab = Utils.get_crontab()
		self.assertTrue(entry in user_crontab)
예제 #15
0
	def test_hour_minute_12h(self):
		entry = b"47 16 * * * ls # SuperCron__TEST__ls"
		args = Namespace(Utils.list_to_dict("TEST__ls", "ls", "at 4:47 pm"))
		SuperCron.add_job(args)
		user_crontab = Utils.get_crontab()
		self.assertTrue(entry in user_crontab)
예제 #16
0
	def test_every_x_minutes(self):
		entry = b"*/5 * * * * ls # SuperCron__TEST__ls"
		args = Namespace(Utils.list_to_dict("TEST__ls", "ls", "once every 5 minutes"))
		SuperCron.add_job(args)
		user_crontab = Utils.get_crontab()
		self.assertTrue(entry in user_crontab)
예제 #17
0
	def test_at_boot(self):
		entry = b"@reboot ls # SuperCron__TEST__ls"
		args = Namespace(Utils.list_to_dict("TEST__ls", "ls", "at reboot"))
		SuperCron.add_job(args)
		user_crontab = Utils.get_crontab()
		self.assertTrue(entry in user_crontab)
예제 #18
0
	def setUp(self):
		Utils.DEBUG = False
		args = Namespace(Utils.list_to_dict("TEST__echo1", "echo 1 > /dev/null", "11:11"))
		SuperCron.add_job(args)
		args = Namespace(Utils.list_to_dict("TEST__echo2", "echo 2 > /dev/null", "12:12"))
		SuperCron.add_job(args)
예제 #19
0
	def setUp(self):
		Utils.DEBUG = False
		args = Namespace(Utils.list_to_dict("TEST__pwd", "pwd", "10:10"))
		SuperCron.add_job(args)
예제 #20
0
	def test_mixed_month_time(self):
		entry = b"55 12 * 8 * ls # SuperCron__TEST__ls"
		args = Namespace(Utils.list_to_dict("TEST__ls", "ls", "in august at 12:55 pm"))
		SuperCron.add_job(args)
		user_crontab = Utils.get_crontab()
		self.assertTrue(entry in user_crontab)
예제 #21
0
	def test_mixed_weekday_time(self):
		entry = b"0 9 * * 1 ls # SuperCron__TEST__ls"
		args = Namespace(Utils.list_to_dict("TEST__ls", "ls", "on monday 09:00"))
		SuperCron.add_job(args)
		user_crontab = Utils.get_crontab()
		self.assertTrue(entry in user_crontab)