@@ -0,0 +1,2445 @@
+# Licensed to the StackStorm, Inc ('StackStorm') under one or more%0A# contributor license agreements.  See the NOTICE file distributed with%0A# this work for additional information regarding copyright ownership.%0A# The ASF licenses this file to You under the Apache License, Version 2.0%0A# (the %22License%22); you may not use this file except in compliance with%0A# the License.  You may obtain a copy of the License at%0A#%0A#     http://www.apache.org/licenses/LICENSE-2.0%0A#%0A# Unless required by applicable law or agreed to in writing, software%0A# distributed under the License is distributed on an %22AS IS%22 BASIS,%0A# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A# See the License for the specific language governing permissions and%0A# limitations under the License.%0A%0Afrom __future__ import absolute_import%0A%0Aimport os%0A%0Aimport unittest2%0Aimport mock%0A%0Afrom st2client.utils.terminal import DEFAULT_TERMINAL_SIZE_LINES%0Afrom st2client.utils.terminal import DEFAULT_TERMINAL_SIZE_COLUMNS%0Afrom st2client.utils.terminal import get_terminal_size%0A%0A__all__ = %5B%0A    'TerminalUtilsTestCase'%0A%5D%0A%0A%0Aclass TerminalUtilsTestCase(unittest2.TestCase):%0A    @mock.patch.dict(os.environ, %7B'LINES': '111', 'COLUMNS': '222'%7D)%0A    def test_get_terminal_size_lines_columns_environment_variable_have_precedence(self):%0A        # Verify that LINES and COLUMNS environment variables have precedence over other approaches%0A        lines, columns = get_terminal_size()%0A%0A        self.assertEqual(lines, 111)%0A        self.assertEqual(columns, 222)%0A%0A    @mock.patch('struct.unpack', mock.Mock(side_effect=Exception('a')))%0A    @mock.patch('subprocess.Popen')%0A    def test_get_terminal_size_subprocess_popen_is_used(self, mock_popen):%0A        mock_communicate = mock.Mock(return_value=%5B'555 666'%5D)%0A%0A        mock_process = mock.Mock()%0A        mock_process.returncode = 0%0A        mock_process.communicate = mock_communicate%0A%0A        mock_popen.return_value = mock_process%0A%0A        lines, columns = get_terminal_size()%0A        self.assertEqual(lines, 555)%0A        self.assertEqual(columns, 666)%0A%0A    @mock.patch('struct.unpack', mock.Mock(side_effect=Exception('a')))%0A    @mock.patch('subprocess.Popen', mock.Mock(side_effect=Exception('b')))%0A    def test_get_terminal_size_default_values_are_used(self):%0A        lines, columns = get_terminal_size()%0A%0A        self.assertEqual(lines, DEFAULT_TERMINAL_SIZE_LINES)%0A        self.assertEqual(columns, DEFAULT_TERMINAL_SIZE_COLUMNS)%0A

Add tests for get_terminal_size.