def test_rmq_restarts_ex ceeded commSpooler CommunicationSpooler commS

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
def test_rmq_restarts_exceeded():
commSpooler = CommunicationSpooler()
commSpooler.lockFileExists = Mock(return_value=True)
with patch.object(commSpooler, "mqPublisher", spec=PublisherProxy) as publisherMock:
publisherMock.isAlive = Mock(return_value=False)
for _ in xrange(Definition_h.COMMSPOOLER_RMQ_CLIENT_MAX_RESTARTS):
commSpooler.createSelfcheckReport()
with pytest.raises(SelfcheckShutdownException) as excinfo:
commSpooler.createSelfcheckReport()
assert str(excinfo.value) == (
"The maximum allowed number of restarts ({maxRestarts}) for RabbitMQ client ({client}) has been exceeded. "
"Commspooler has been automatically stopped."
).format(maxRestarts=Definition_h.COMMSPOOLER_RMQ_CLIENT_MAX_RESTARTS, client=str(publisherMock))