def test_calculate_width_1col(self, settings_mock): self.popen.return_value.communicate.return_value = ('999 1', 0) settings_mock.TARGET_SETTINGS = {'original_hosts': [ 'foo01', 'foo02 foo03', 'foo04 foo05 foo06', 'foo07 foo08']} expected = ['matrix', 'color', '1col'] result = calculate_info_view_settings() self.assertEqual(result, expected)
def test_calculate_width_when_stty_fails(self, settings_mock): self.popen.return_value.communicate.return_value = (None, 1) settings_mock.TARGET_SETTINGS = {'original_hosts': [ 'foo01 foo02 foo03 foo04 foo05 foo06 foo07 foo08']} expected = ['matrix', 'color', '3cols'] result = calculate_info_view_settings() self.assertEqual(result, expected)
def test_calculate_width_when_regular_expr_is_in_orig_hosts(self, he_mock, settings_mock): he_mock.return_value = xrange(0, 40) self.popen.return_value.communicate.return_value = ('999 80', 0) settings_mock.TARGET_SETTINGS = {'original_hosts': [ 'foo01', 'foo02 foo03', 'foo[4..44]', 'foo45 foo46']} expected = ['matrix', 'color', '1col'] result = calculate_info_view_settings() self.assertEqual(result, expected)