예제 #1
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)
예제 #2
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)
예제 #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_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)
예제 #6
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)
예제 #7
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)
예제 #8
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)
예제 #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_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)
예제 #11
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)
예제 #12
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)
예제 #13
0
	def test_enable_job(self):
		entry = b"10 10 * * * pwd # SuperCron__TEST__pwd"
		dis_entry = b"# " + entry
		args = Namespace(Utils.list_to_dict("TEST__pwd"))
		SuperCron.disable_job(args)
		SuperCron.enable_job(args)
		user_crontab = Utils.get_crontab()
		self.assertTrue(entry in user_crontab and dis_entry not in user_crontab)
예제 #14
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)
예제 #15
0
	def test_trigger_addition_removal(self):
		entry1 = b"11 11 * * * echo 1 > /dev/null # SuperCron__TEST__echo1"
		entry2 = b"11 11 * * * echo 1 > /dev/null # SuperCron__TEST__echo1%off:TEST__echo2:deleted"
		args2 = Namespace({"name": "TEST__echo1", "trigger": ["off if TEST__echo2 is deleted"]})
		SuperCron.trigger_job(args2)
		user_crontab = Utils.get_crontab()
		test1 = entry2 in user_crontab
		args2 = Namespace({"name": "TEST__echo1", "trigger": ["none"]})
		SuperCron.trigger_job(args2)
		user_crontab = Utils.get_crontab()
		test2 = entry1 in user_crontab and not entry2 in user_crontab
		self.assertTrue(test1 and test2)
예제 #16
0
	def test_trigger_off_if_deleted(self):
		entry = b"# 11 11 * * * echo 1 > /dev/null # SuperCron__TEST__echo1%off:TEST__echo2:deleted"
		args2 = Namespace({"name": "TEST__echo1", "trigger": ["off if TEST__echo2 is deleted"]})
		SuperCron.trigger_job(args2)
		args1 = Namespace({"name": "TEST__echo2"})
		SuperCron.delete_job(args1)
		user_crontab = Utils.get_crontab()
		self.assertTrue(entry in user_crontab)
예제 #17
0
	def test_rename_job(self):
		entry1 = b"10 10 * * * pwd # SuperCron__TEST__pwd"
		entry2 = b"10 10 * * * pwd # SuperCron__TEST__ls"
		args = Namespace({"old_name": "TEST__pwd", "new_name": "TEST__ls"})
		SuperCron.rename_job(args)
		user_crontab = Utils.get_crontab()
		rename_check = entry1 not in user_crontab and entry2 in user_crontab
		args = Namespace({"old_name": "TEST__ls", "new_name": "TEST__pwd"})
		SuperCron.rename_job(args)
		self.assertTrue(rename_check)
예제 #18
0
	def test_trigger_on_if_deleted(self):
		entry1 = b"11 11 * * * echo 1 > /dev/null # SuperCron__TEST__echo1%on:TEST__echo2:deleted"
		entry2 = b"# 11 11 * * * echo 1 > /dev/null # SuperCron__TEST__echo1%on:TEST__echo2:deleted"
		args1 = Namespace({"name": "TEST__echo1"})
		SuperCron.disable_job(args1)
		args2 = Namespace({"name": "TEST__echo1", "trigger": ["on if TEST__echo2 is deleted"]})
		SuperCron.trigger_job(args2)
		args1 = Namespace({"name": "TEST__echo2"})
		SuperCron.delete_job(args1)
		user_crontab = Utils.get_crontab()
		self.assertTrue(entry1 in user_crontab and not entry2 in user_crontab)
예제 #19
0
	def test_clear_jobs(self):
		entry = b"10 10 * * * pwd # SuperCron__TEST__pwd"
		args = Namespace({"force": True})
		SuperCron.clear_jobs(args)
		user_crontab = Utils.get_crontab()
		self.assertTrue(entry not in user_crontab)
예제 #20
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)
예제 #21
0
	def setUp(self):
		Utils.DEBUG = False
		args = Namespace(Utils.list_to_dict("TEST__pwd", "pwd", "10:10"))
		SuperCron.add_job(args)
예제 #22
0
	def tearDown(self):
		args = Namespace(Utils.list_to_dict("TEST__echo1"))
		SuperCron.delete_job(args)
		args = Namespace(Utils.list_to_dict("TEST__echo2"))
		SuperCron.delete_job(args)
예제 #23
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)
예제 #24
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)
예제 #25
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)
예제 #26
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)
예제 #27
0
	def test_search_job_zero(self):
		entry = b"10 10 * * * pwd # SuperCron__TEST__pwd"
		args = Namespace(Utils.list_to_dict("TEST__pwd"))
		SuperCron.delete_job(args)
		self.assertTrue(SuperCron.search_job(args) != -1)
예제 #28
0
	def test_search_job_all(self):
		entry = b"10 10 * * * pwd # SuperCron__TEST__pwd"
		args = Namespace(Utils.list_to_dict("@all"))
		self.assertTrue(SuperCron.search_job(args) != -1)
예제 #29
0
	def test_delete_job(self):
		entry = b"10 10 * * * pwd # SuperCron__TEST__pwd"
		args = Namespace(Utils.list_to_dict("TEST__pwd"))
		SuperCron.delete_job(args)
		user_crontab = Utils.get_crontab()
		self.assertTrue(entry not in user_crontab)
예제 #30
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)