def test_method_column_widths_object_new_column(self): mock_line_data = MagicMock() mock_line_data.size = (20, 20) mock_column_1 = MagicMock(spec=DisplayColumn) mock_column_1.align = 'left' mock_column_1.attribute = 'test' mock_column_1.colspan = 1 mock_column_1.default = None mock_column_1.formatter = PropertyMock(return_value=mock_line_data) mock_column_1.formatter_args = None mock_column_1.lookup = None mock_column_2 = MagicMock(spec=DisplayColumn) mock_column_2.align = 'left' mock_column_2.attribute = 'test' mock_column_2.colspan = 1 mock_column_2.default = None mock_column_2.formatter = PropertyMock(return_value=mock_line_data) mock_column_2.formatter_args = None mock_column_2.lookup = None mock_data = MagicMock(test="test") column_widths = [40] instance = DisplayLine([mock_column_1, mock_column_2], mock_data) instance._column_widths = column_widths expected_result = [40, 20] self.assertListEqual( instance.column_widths(sentinel.font, column_widths), expected_result)
def test_method_column_widths_string_new_column(self): mock_column_1 = MagicMock(spec=DisplayColumn) mock_column_1.align = 'left' mock_column_1.attribute = 'test' mock_column_1.colspan = 1 mock_column_1.default = None mock_column_1.formatter = None mock_column_1.lookup = None mock_column_2 = MagicMock(spec=DisplayColumn) mock_column_2.align = 'left' mock_column_2.attribute = 'test' mock_column_2.colspan = 1 mock_column_2.default = None mock_column_2.formatter = None mock_column_2.lookup = None mock_data = MagicMock(test="test") mock_font = MagicMock() mock_font.getsize.return_value = (20, 20) column_widths = [40] instance = DisplayLine([mock_column_1, mock_column_2], mock_data) instance._column_widths = column_widths expected_result = [40, 20] self.assertListEqual(instance.column_widths(mock_font, column_widths), expected_result)