def test_stop(self, mocks, mocker): subject = TrafficHandler('snow', self.mock_traffic_commands) self.mock_traffic_commands.cleanup = 'cleanup command' mock_first_traffic = mocker.Mock() mock_second_traffic = mocker.Mock() subject.traffic_handles = [mock_first_traffic, mock_second_traffic] subject.stop() mock_first_traffic.cleanup.assert_called_with('cleanup command') mock_second_traffic.cleanup.assert_called_with('cleanup command') assert not subject.traffic_handles assert self.mock_print.mock_calls == [mocker.call('\tdone.')]
def test_verify(self, mocks, mocker): subject = TrafficHandler('snow', self.mock_traffic_commands) mock_first_traffic = mocker.Mock() mock_first_traffic.status.return_value = 'first: SUCCESS' mock_second_traffic = mocker.Mock() mock_second_traffic.status.return_value = 'second: FAILURE' subject.traffic_handles = [mock_first_traffic, mock_second_traffic] subject.verify() assert self.mock_print.mock_calls == [ mocker.call('snow - first: SUCCESS'), mocker.call('snow - second: FAILURE'), mocker.call(''), ]