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())
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)
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)
def test_label_printer1(self): """Assert fails if template not set.""" label = ModelLabel() TestModelFactory() label.zpl_template = self.zpl_template
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))
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')