Ejemplo n.º 1
0
 def test_label_context(self):
     """Assert can refresh the label context with the model instance."""
     label = ModelLabel()
     label.zpl_template = self.zpl_template
     test_model = TestModelFactory()
     label.model_instance = test_model
     self.assertTrue(label.refresh_label_context())
Ejemplo n.º 2
0
 def test_print_label(self):
     """Assert sends error message if printer is not known to lpr."""
     test_model = TestModelFactory()
     label = ModelLabel()
     label.zpl_template = self.zpl_template
     label.default_label_printer = self.label_printer_default
     request = None
     label.print_label(request, test_model, update_messages=False, client_addr='127.0.0.1')
     self.assertIn('printer or class does not exist', label.error_message)
Ejemplo n.º 3
0
 def test_formatted_label_string(self):
     """Assert model values are in formatted label string."""
     label = ModelLabel()
     label.zpl_template = self.zpl_template
     test_model = TestModelFactory()
     label.model_instance = test_model
     label.refresh_label_context()
     self.assertIn(label.label_context.get('f1'), label.formatted_label_string)
     self.assertIn(label.label_context.get('f2'), label.formatted_label_string)
     self.assertIn(label.label_context.get('f3'), label.formatted_label_string)
     self.assertIn(label.label_context.get('f4'), label.formatted_label_string)
     self.assertIn(label.label_context.get('created'), label.formatted_label_string)
     self.assertIn(label.label_context.get('barcode_value'), label.formatted_label_string)
Ejemplo n.º 4
0
 def test_label_printer1(self):
     """Assert fails if template not set."""
     label = ModelLabel()
     TestModelFactory()
     label.zpl_template = self.zpl_template
Ejemplo n.º 5
0
 def test_label_printer(self):
     """Assert fails if template not set."""
     label = ModelLabel()
     label.zpl_template = self.zpl_template
     self.assertIsNotNone(label.label_printer)
     self.assertTrue(isinstance(label.label_printer, LabelPrinter))
Ejemplo n.º 6
0
 def test_zpl_template_not_set(self):
     """Assert fails if template not set."""
     label = ModelLabel()
     test_model = TestModelFactory()
     request = None
     self.assertRaises(TypeError, label.print_label, request, test_model, update_messages=False, client_addr='127.0.0.1')