-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
AAP-39559 Wait for all event processing to finish, add fallback task (#…
…15798) * Wait for all event processing to finish, add fallback task * Add flag check to periodic task
- Loading branch information
1 parent
e2151ae
commit bc08e03
Showing
5 changed files
with
165 additions
and
55 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import copy | ||
|
||
import pytest | ||
|
||
from awx.main.tasks.host_indirect import get_hashable_form | ||
|
||
|
||
class TestHashableForm: | ||
@pytest.mark.parametrize( | ||
'data', | ||
[ | ||
{'a': 'b'}, | ||
['a', 'b'], | ||
('a', 'b'), | ||
{'a': {'b': 'c'}}, | ||
{'a': ['b', 'c']}, | ||
{'a': ('b', 'c')}, | ||
['a', ['b', 'c']], | ||
['a', ('b', 'c')], | ||
['a', {'b': 'c'}], | ||
], | ||
) | ||
def test_compare_equal_data(self, data): | ||
other_data = copy.deepcopy(data) | ||
# A tuple of scalars may be cached so ids could legitimately be the same | ||
if data != ('a', 'b'): | ||
assert id(data) != id(other_data) # sanity | ||
assert id(get_hashable_form(data)) != id(get_hashable_form(data)) | ||
|
||
assert get_hashable_form(data) == get_hashable_form(data) | ||
assert hash(get_hashable_form(data)) == hash(get_hashable_form(data)) | ||
|
||
assert get_hashable_form(data) in {get_hashable_form(data): 1} # test lookup hit | ||
|
||
@pytest.mark.parametrize( | ||
'data, other_data', | ||
[ | ||
[{'a': 'b'}, {'a': 'c'}], | ||
[{'a': 'b'}, {'a': 'b', 'c': 'd'}], | ||
[['a', 'b'], ['a', 'c']], | ||
[('a', 'b'), ('a', 'c')], | ||
[{'a': {'b': 'c'}}, {'a': {'b': 'd'}}], | ||
[{'a': ['b', 'c']}, {'a': ['b', 'd']}], | ||
[{'a': ('b', 'c')}, {'a': ('b', 'd')}], | ||
[['a', ['b', 'c']], ['a', ['b', 'd']]], | ||
[['a', ('b', 'c')], ['a', ('b', 'd')]], | ||
[['a', {'b': 'c'}], ['a', {'b': 'd'}]], | ||
], | ||
) | ||
def test_compar_different_data(self, data, other_data): | ||
assert data != other_data # sanity, otherwise why test this? | ||
assert get_hashable_form(data) != get_hashable_form(other_data) | ||
assert hash(get_hashable_form(data)) != hash(get_hashable_form(other_data)) | ||
|
||
assert get_hashable_form(other_data) not in {get_hashable_form(data): 1} # test lookup miss | ||
assert get_hashable_form(data) not in {get_hashable_form(other_data): 1} |
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