Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NAS-130907 / 25.04 / Removed REST from test_150_cronjob #14399

Merged
merged 2 commits into from
Sep 3, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 0 additions & 71 deletions tests/api2/test_150_cronjob.py

This file was deleted.

52 changes: 52 additions & 0 deletions tests/api2/test_cronjob.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import pytest
aiden3c marked this conversation as resolved.
Show resolved Hide resolved
from time import sleep

from middlewared.test.integration.utils import call, ssh

TESTFILE = '/tmp/.testFileCreatedViaCronjob'
yocalebo marked this conversation as resolved.
Show resolved Hide resolved


@pytest.fixture(scope='module')
def cronjob_dict():
return {}


def creating_new_cron_job_which_will_run_every_minute(cronjob_dict):
aiden3c marked this conversation as resolved.
Show resolved Hide resolved
results = call("cronjob.create", {
'user': 'root',
'command': f'touch "{TESTFILE}"',
'schedule': {'minute': '*/1'}
})
cronjob_dict.update(results)


def checking_to_see_if_cronjob_was_created_and_enabled(cronjob_dict):
aiden3c marked this conversation as resolved.
Show resolved Hide resolved
id = cronjob_dict['id']
results = call('cronjob.query', [['id', '=', id]], {"get": True})
assert results['enabled'] is True


def wait_a_minute():
sleep(65)


def updating_cronjob_status_to_disabled_updating_command(cronjob_dict):
id = cronjob_dict['id']
call('cronjob.update', id, {'enabled': False})


def checking_that_API_reports_the_cronjob_as_updated(cronjob_dict):
aiden3c marked this conversation as resolved.
Show resolved Hide resolved
id = cronjob_dict['id']
results = call('cronjob.query', [['id', '=', id]], {"get": True})
assert results['enabled'] is False


def deleting_test_file_created_by_cronjob(request):
results = ssh(f'rm "{TESTFILE}"', complete_response=True)
assert results['result'] is True, results['output']


def delete_and_check_cron_job(cronjob_dict):
call('cronjob.delete', cronjob_dict['id'])
results = call('cronjob.query', [['id', '=', id]], {"get": True})
assert results.json() == []
Loading