def _CreateAvailabilityLine(header, items, header_indent=2, items_indent=25, line_length=80): items_width = line_length - items_indent items_text = '\n'.join(formatting.WrappedJoin(items, width=items_width)) indented_items_text = formatting.Indent(items_text, spaces=items_indent) indented_header = formatting.Indent(header, spaces=header_indent) return indented_header + indented_items_text[len(indented_header):] + '\n'
def test_wrap_multiple_items(self): lines = formatting.WrappedJoin(['rice', 'beans', 'chicken', 'cheese'], width=15) self.assertEqual(['rice | beans |', 'chicken |', 'cheese'], lines)
def test_wrap_one_item(self): lines = formatting.WrappedJoin(['rice']) self.assertEqual(['rice'], lines)
def test_wrap_multiple_items(self): lines = formatting.WrappedJoin(["rice", "beans", "chicken", "cheese"], width=15) self.assertEqual(["rice | beans |", "chicken |", "cheese"], lines)