-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #962 from scitran/rules-enqueue
Use central job enqueue logic for jobs spawned by rules
- Loading branch information
Showing
5 changed files
with
83 additions
and
5 deletions.
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
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 |
---|---|---|
@@ -0,0 +1,56 @@ | ||
|
||
import copy | ||
from api.jobs import gears | ||
|
||
# DISCUSS: this basically asserts that the log helper doesn't throw, which is of non-zero but questionable value. | ||
# Could instead be marked for pytest et. al to ignore coverage? Desirability? Compatibility? | ||
def test_fill_defaults(): | ||
|
||
gear_config = { | ||
'key_one': {'default': 1}, | ||
'key_two': {'default': 2}, | ||
'key_three': {'default': 3}, | ||
'key_no_de': {} | ||
} | ||
|
||
gear = { | ||
'gear': { | ||
'config': gear_config | ||
} | ||
} | ||
|
||
# test sending in complete config does not change | ||
config = { | ||
'key_one': 4, | ||
'key_two': 5, | ||
'key_three': 6 | ||
} | ||
|
||
result = gears.fill_gear_default_values(gear, config) | ||
assert result['key_one'] == 4 | ||
assert result['key_two'] == 5 | ||
assert result['key_three'] == 6 | ||
|
||
# test sending in empty config | ||
result = gears.fill_gear_default_values(gear, {}) | ||
assert result['key_one'] == 1 | ||
assert result['key_two'] == 2 | ||
assert result['key_three'] == 3 | ||
|
||
# test sending in None config | ||
result = gears.fill_gear_default_values(gear, None) | ||
assert result['key_one'] == 1 | ||
assert result['key_two'] == 2 | ||
assert result['key_three'] == 3 | ||
|
||
# test sending in semi-complete config | ||
config = { | ||
'key_one': None, | ||
'key_two': [] | ||
#'key_three': 6 # missing | ||
} | ||
|
||
result = gears.fill_gear_default_values(gear, config) | ||
assert result['key_one'] == None | ||
assert result['key_two'] == [] | ||
assert result['key_three'] == 3 |