def test_container_attach_event(self, thread_map, mock_presenters):
     container_id = 'abcd'
     mock_container = mock.Mock(is_restarting=False)
     mock_container.attach_log_stream.side_effect = APIError("race condition")
     event_die = {'action': 'die', 'id': container_id}
     event_start = {'action': 'start', 'id': container_id, 'container': mock_container}
     event_stream = [event_die, event_start]
     thread_args = 'foo', 'bar'
     watch_events(thread_map, event_stream, mock_presenters, thread_args)
     assert mock_container.attach_log_stream.called
Exemple #2
0
    def test_start_event(self, thread_map, mock_presenters):
        container_id = "abcd"
        event = {"action": "start", "id": container_id, "container": mock.Mock()}
        event_stream = [event]
        thread_args = "foo", "bar"

        with mock.patch("compose.cli.log_printer.build_thread", autospec=True) as mock_build_thread:
            watch_events(thread_map, event_stream, mock_presenters, thread_args)
            mock_build_thread.assert_called_once_with(event["container"], next(mock_presenters), *thread_args)
        assert container_id in thread_map
Exemple #3
0
    def test_start_event(self, thread_map, mock_presenters):
        container_id = 'abcd'
        event = {'action': 'start', 'id': container_id, 'container': mock.Mock()}
        event_stream = [event]
        thread_args = 'foo', 'bar'

        with mock.patch(
            'compose.cli.log_printer.build_thread',
            autospec=True
        ) as mock_build_thread:
            watch_events(thread_map, event_stream, mock_presenters, thread_args)
            mock_build_thread.assert_called_once_with(
                event['container'],
                next(mock_presenters),
                *thread_args)
        assert container_id in thread_map
Exemple #4
0
 def test_other_event(self, thread_map, mock_presenters):
     container_id = 'abcd'
     event_stream = [{'action': 'create', 'id': container_id}]
     watch_events(thread_map, event_stream, mock_presenters, ())
     assert container_id not in thread_map
Exemple #5
0
 def test_stop_event(self, thread_map, mock_presenters):
     event_stream = [{'action': 'stop', 'id': 'cid'}]
     watch_events(thread_map, event_stream, mock_presenters, ())
     assert not thread_map
Exemple #6
0
 def test_other_event(self, thread_map, mock_presenters):
     container_id = 'abcd'
     event_stream = [{'action': 'create', 'id': container_id}]
     watch_events(thread_map, event_stream, mock_presenters, ())
     assert container_id not in thread_map
Exemple #7
0
 def test_stop_event(self, thread_map, mock_presenters):
     event_stream = [{'action': 'stop', 'id': 'cid'}]
     watch_events(thread_map, event_stream, mock_presenters, ())
     assert not thread_map
Exemple #8
0
 def test_other_event(self, thread_map, mock_presenters):
     container_id = "abcd"
     event_stream = [{"action": "create", "id": container_id}]
     watch_events(thread_map, event_stream, mock_presenters, ())
     assert container_id not in thread_map
Exemple #9
0
 def test_stop_event(self, thread_map, mock_presenters):
     event_stream = [{"action": "stop", "id": "cid"}]
     watch_events(thread_map, event_stream, mock_presenters, ())
     assert not thread_map