diff --git a/tests/cron_handler_test.py b/tests/cron_handler_test.py index 4e97f07..b112ed0 100644 --- a/tests/cron_handler_test.py +++ b/tests/cron_handler_test.py @@ -5,6 +5,7 @@ sys.path.insert(0,'..') from cron_handler import CronHandler from utils import get_env_data_as_dict +import os ## TODO make this a legit pytest ## UNIT TEST ALL THE THINGS!! @@ -20,7 +21,7 @@ async def main(): env_vars = {'SHELL': '/usr/bin/bash', 'API_URL': 'http://localhost:8000'} # unique job id number to be placed in comment - comment = "cron now ls" + comment = "cron python script" echo_comment = "cron now echo" now = dt.datetime.now() @@ -29,17 +30,17 @@ async def main(): ch = CronHandler(username) # regular cron job with comment - response = await ch.new_job("ls", "* * * * *", comment=comment) + response = await ch.new_job("ls", "15 * * * *", comment=comment) print(response) - # regular cron job with aliase - response = await ch.new_job("ls", "@hourly", comment=comment) + # regular cron job with alias + dir_path = os.path.dirname(os.path.realpath(__file__)) + response = await ch.new_job(f"/usr/bin/python3 {dir_path}/../log_handler.py", "* * * * *", comment=comment) print(response) - # cron job with env vars - response = await ch.new_job_with_env("echo", "* * * * *", comment=echo_comment, env=env_vars) - print(response) + # response = await ch.new_job_with_env("echo", "@hourly", comment=echo_comment, env=env_vars) + # print(response) # enable job print("Enable Job by Comment") @@ -71,12 +72,11 @@ async def main(): # validate cron string is valid cron_string = '@reboot' is_valid = await ch.validate_cron_string(cron_string) - print(f'cron string {cron_string} is valid: {is_valid}') - + print(f'cron string {cron_string} is valid: {is_valid}') # set env vars - print("set env vars") - await ch.set_env_vars(env_vars) + #print("set env vars") + #await ch.set_env_vars(env_vars) # print environment variables print("get env vars")