Skip to content

Commit

Permalink
Add unit tests for sequence_status_check_functions() (#585)
Browse files Browse the repository at this point in the history
Add missing unit tests for sequence_status_check_functions() helper
introduced in PR #584.

Signed-off-by: Przemysław Lal <[email protected]>
  • Loading branch information
przemeklal authored Mar 5, 2021
1 parent e3a594f commit dc8b7ea
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions tests/contrib/openstack/test_os_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,3 +275,25 @@ def test_ordered(self):
self.assertEqual(expected, utils.ordered(data))

self.assertRaises(ValueError, utils.ordered, "foo")

def test_sequence_status_check_functions(self):
# all messages are reported and the highest priority status "wins"
f1 = mock.Mock(return_value=('blocked', 'status 1'))
f2 = mock.Mock(return_value=('', 'status 2'))
f3 = mock.Mock(return_value=('maintenance', 'status 3'))
f = utils.sequence_status_check_functions(f1, f2, f3)
expected = ('blocked', 'status 1, status 2, status 3')
result = f(mock.Mock())
self.assertEquals(result, expected)
# empty status must be replaced by "unknown"
f4 = mock.Mock(return_value=('', 'status 4'))
f5 = mock.Mock(return_value=('', 'status 5'))
f = utils.sequence_status_check_functions(f4, f5)
expected = ('unknown', 'status 4, status 5')
result = f(mock.Mock())
self.assertEquals(result, expected)
# sequencing 0 status checks must return state 'unknown', ''
f = utils.sequence_status_check_functions()
expected = ('unknown', '')
result = f(mock.Mock())
self.assertEquals(result, expected)

0 comments on commit dc8b7ea

Please sign in to comment.