def test_can_print_to_pdf(self): lp = LabelPrinter(self.title, self.barcode) path = lp.print_to_pdf() self.__removable_files.append(path) assert os.path.isfile(path)
def _get_label_printer(barcode: Barcode) -> LabelPrinter: title = barcode.item.name if barcode.quantity > 1: title = '{title} ({quantity!s}{unit})'.format( title=title, quantity=str(barcode.quantity).rstrip('0').rstrip('.'), unit=barcode.item.unit.unit) return LabelPrinter(title=title, data=barcode.barcode)
def test_print_to_pdf_generated_pdf_only_once_with_same_metadata(self): lp1 = LabelPrinter(self.title, self.barcode) lp2 = LabelPrinter(self.title, self.barcode) path1 = lp1.print_to_pdf() self.__removable_files.append(path1) stat1 = os.stat(path1) path2 = lp2.print_to_pdf() self.__removable_files.append(path2) stat2 = os.stat(path2) assert path1 == path2 assert stat1 is not stat2 assert stat1 == stat2
def test_can_print(self): printer = PrinterMock() lp = LabelPrinter(self.title, self.barcode) lp.print(printer) assert printer.last_printed_pdf is not None
def test_can_create_label_printer(self): LabelPrinter(self.title, self.barcode)
def _get_label_printer(barcode: Barcode) -> LabelPrinter: title = barcode.item.name if barcode.quantity > 1: title = '{} ({!s}{})'.format(title, barcode.quantity, barcode.item.unit.unit) return LabelPrinter(title=title, data=barcode.barcode)