def test_should_set_given_log_level(self, mock_formatter_class, mock_stream_handler_class):

        mock_handler = Mock()
        mock_stream_handler_class.return_value = mock_handler

        create_console_handler(ERROR)

        mock_handler.setLevel.assert_called_with(ERROR)
    def test_should_set_given_log_level(self, mock_formatter_class,
                                        mock_stream_handler_class):

        mock_handler = Mock()
        mock_stream_handler_class.return_value = mock_handler

        create_console_handler(ERROR)

        mock_handler.setLevel.assert_called_with(ERROR)
    def test_should_initialze_formatter_and_use_it(self, mock_formatter_class, mock_stream_handler_class):

        mock_formatter = Mock()
        mock_formatter_class.return_value = mock_formatter
        mock_handler = Mock()
        mock_stream_handler_class.return_value = mock_handler

        create_console_handler(ERROR)

        mock_formatter_class.assert_called_with("[%(levelname)5s] %(message)s")
        mock_handler.setFormatter.assert_called_with(mock_formatter)
    def test_should_initialze_formatter_and_use_it(self, mock_formatter_class,
                                                   mock_stream_handler_class):

        mock_formatter = Mock()
        mock_formatter_class.return_value = mock_formatter
        mock_handler = Mock()
        mock_stream_handler_class.return_value = mock_handler

        create_console_handler(ERROR)

        mock_formatter_class.assert_called_with('[%(levelname)5s] %(message)s')
        mock_handler.setFormatter.assert_called_with(mock_formatter)
    def test_should_return_created_console_handler(self, mock_formatter_class, mock_stream_handler_class):

        mock_handler = Mock()
        mock_stream_handler_class.return_value = mock_handler

        actual_handler = create_console_handler(ERROR)

        self.assertEqual(mock_handler, actual_handler)
    def test_should_return_created_console_handler(self, mock_formatter_class,
                                                   mock_stream_handler_class):

        mock_handler = Mock()
        mock_stream_handler_class.return_value = mock_handler

        actual_handler = create_console_handler(ERROR)

        self.assertEqual(mock_handler, actual_handler)