mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-05-28 03:49:09 -07:00
Cache tasks by uuid in PlayIterator for O(1) lookups
Rather than repeatedly searching for tasks by uuid via iterating over all known blocks, cache the tasks when they are added to the PlayIterator so the lookup becomes a simple key check in a dict.
This commit is contained in:
parent
125c53e691
commit
47acf55fa9
3 changed files with 25 additions and 43 deletions
|
@ -329,7 +329,7 @@ class TestPlayIterator(unittest.TestCase):
|
|||
# test the high-level add_tasks() method
|
||||
s = HostState(blocks=[0,1,2])
|
||||
itr._insert_tasks_into_state = MagicMock(return_value=s)
|
||||
itr.add_tasks(hosts[0], [3,4,5])
|
||||
itr.add_tasks(hosts[0], [MagicMock(), MagicMock(), MagicMock()])
|
||||
self.assertEqual(itr._host_states[hosts[0].name], s)
|
||||
|
||||
# now actually test the lower-level method that does the work
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue