def testThrottlesTreeOnOpen(self): """Tests that ThrottleOrCloseTheTree throttles the tree if tree is open.""" self._SetupMockTreeStatusResponses(final_tree_status='Tree is open (taco)', final_general_state=constants.TREE_OPEN) with mock.patch.object(tree_status, '_UpdateTreeStatus') as m: tree_status.ThrottleOrCloseTheTree('foo', 'failure') m.assert_called_once_with(mock.ANY, 'Tree is throttled (foo: failure)')
def testClosesTheTreeOnClosed(self): """Tests ThrottleOrCloseTheTree closes the tree if tree is closed.""" self._SetupMockTreeStatusResponses( final_tree_status='Tree is closed (taco)', final_general_state=constants.TREE_CLOSED) with mock.patch.object(tree_status, '_UpdateTreeStatus') as m: tree_status.ThrottleOrCloseTheTree('foo', 'failure') m.assert_called_once_with(mock.ANY, 'Tree is closed (foo: failure | taco)')
def testThrottlesTreeOnWithBuildNumberAndPublicType(self): """Tests that tree is throttled with the build number in the message.""" self._SetupMockTreeStatusResponses(final_tree_status='Tree is open (taco)', final_general_state=constants.TREE_OPEN) with mock.patch.object(tree_status, '_UpdateTreeStatus') as m: tree_status.ThrottleOrCloseTheTree('foo', 'failure', buildnumber=1234, internal=False) m.assert_called_once_with(mock.ANY, 'Tree is throttled (foo-p-1234: failure)')
def testDiscardUpdateFromTheSameAnnouncer(self): """Tests we don't include messages from the same announcer.""" self._SetupMockTreeStatusResponses( final_tree_status='Tree is throttled (foo: failure | bar: taco)', final_general_state=constants.TREE_THROTTLED) with mock.patch.object(tree_status, '_UpdateTreeStatus') as m: tree_status.ThrottleOrCloseTheTree('foo', 'failure') # Also make sure that previous status message is included. m.assert_called_once_with(mock.ANY, 'Tree is throttled (foo: failure | bar: taco)')
def testThrottlesTreeOnThrottled(self): """Tests ThrottleOrCloseTheTree throttles the tree if tree is throttled.""" self._SetupMockTreeStatusResponses( final_tree_status='Tree is throttled (taco)', final_general_state=constants.TREE_THROTTLED) with mock.patch.object(tree_status, '_UpdateTreeStatus') as m: tree_status.ThrottleOrCloseTheTree('foo', 'failure') # Also make sure that previous status message is included. m.assert_called_once_with(mock.ANY, 'Tree is throttled (foo: failure | taco)')