-
Notifications
You must be signed in to change notification settings - Fork 114
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
Non-zero exit code on run_job failure #100
Open
palfrey
wants to merge
5
commits into
kraiz:master
Choose a base branch
from
palfrey:exit-code-on-failure
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
3b57b26
Add exit value from run_job
palfrey 2820eec
Make command exit with non-zero code on run_job failure
palfrey ede4948
Add test that run_job returns false on Exception
palfrey 0249872
Fix flake8 issues
palfrey b6e7a8c
Removing "flake8: " prefix to noqa seems to fix the basestring issues
palfrey File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -169,46 +169,54 @@ def test_remove_job_but_keep_anything_else(): | |
@patch('tests.cron.cron_job') | ||
def test_run_no_arg_format1_job(method_to_call): | ||
crontab = Crontab() | ||
crontab.run_job('4f30993ab69a8c5763ce55f762ef0433') | ||
assert crontab.run_job('4f30993ab69a8c5763ce55f762ef0433') | ||
method_to_call.assert_called_with() | ||
|
||
|
||
@override_settings(CRONJOBS=[('*/1 * * * *', 'tests.cron.cron_job', '> /home/myhome/logs/cron_job.log')]) | ||
@patch('tests.cron.cron_job') | ||
def test_run_no_arg_format1_job_with_suffix(method_to_call): | ||
crontab = Crontab() | ||
crontab.run_job('53e6fe5b66bd870e396d574ba1503c33') | ||
assert crontab.run_job('53e6fe5b66bd870e396d574ba1503c33') | ||
method_to_call.assert_called_with() | ||
|
||
|
||
@override_settings(CRONJOBS=[('*/1 * * * *', 'tests.cron.cron_job', [1, 'two'])]) | ||
@patch('tests.cron.cron_job') | ||
def test_run_args_only_format2_job(method_to_call): | ||
crontab = Crontab() | ||
crontab.run_job('369f8418b0f8cf1fff78c547516aa8e0') | ||
assert crontab.run_job('369f8418b0f8cf1fff78c547516aa8e0') | ||
method_to_call.assert_called_with(1, 'two') | ||
|
||
|
||
@override_settings(CRONJOBS=[('*/1 * * * *', 'tests.cron.cron_job', [1, 'two'], {'test': 34, 'a': 's2'})]) | ||
@patch('tests.cron.cron_job') | ||
def test_run_format2_job(method_to_call): | ||
crontab = Crontab() | ||
crontab.run_job('13e8169dffe273b8b0c5f8abe1b6f643') | ||
assert crontab.run_job('13e8169dffe273b8b0c5f8abe1b6f643') | ||
method_to_call.assert_called_with(1, 'two', test=34, a='s2') | ||
|
||
|
||
@override_settings(CRONJOBS=[('*/1 * * * *', 'tests.cron.cron_job', [1, 'two'], dict(), 'some suffix')]) | ||
@patch('tests.cron.cron_job') | ||
def test_run_args_only_format2_job(method_to_call): | ||
def test_run_args_only_format3_job(method_to_call): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I got warnings about this being a duplicate name with the above test, so I renamed it |
||
crontab = Crontab() | ||
crontab.run_job('fefa68aed4ff509331ee6a5b62ea5e5c') | ||
assert crontab.run_job('fefa68aed4ff509331ee6a5b62ea5e5c') | ||
method_to_call.assert_called_with(1, 'two') | ||
|
||
|
||
@override_settings(CRONJOBS=[('*/1 * * * *', 'tests.cron.cron_job')]) | ||
@patch('tests.cron.cron_job', side_effect=Exception('foo')) | ||
def test_job_exception(method_to_call): | ||
crontab = Crontab() | ||
assert not crontab.run_job('4f30993ab69a8c5763ce55f762ef0433') | ||
method_to_call.assert_called_with() | ||
|
||
|
||
@override_settings(CRONJOBS=[('* * * * *', 'tests.test_crontab.recursive_job_for_lock_checking')], CRONTAB_LOCK_JOBS=True) | ||
def test_locked_job(): | ||
crontab = Crontab() | ||
crontab.run_job('4a8e5d03cf136a16c7d120c41efb602b') | ||
assert crontab.run_job('4a8e5d03cf136a16c7d120c41efb602b') | ||
|
||
|
||
def recursive_job_for_lock_checking(): | ||
|
@@ -217,12 +225,12 @@ def recursive_job_for_lock_checking(): | |
else: | ||
recursive_job_for_lock_checking.called_already = True | ||
crontab = Crontab() | ||
crontab.run_job('4a8e5d03cf136a16c7d120c41efb602b') | ||
assert not crontab.run_job('4a8e5d03cf136a16c7d120c41efb602b') | ||
recursive_job_for_lock_checking.called_already = False | ||
|
||
|
||
@raises(RuntimeError) | ||
def test_job_not_found(): | ||
crontab = Crontab() | ||
crontab.run_job('4a8e5d03cf136a16c7d120c41efb602b') | ||
assert not crontab.run_job('4a8e5d03cf136a16c7d120c41efb602b') | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not quite sure why this was now failing, as it's got nothing to do with my changes. Changing to an explicit ignore seems to work fine