示例#1
0
 def test_is_valid_too_short(self):
     """Test an element that's content is too short"""
     element = Element(name="shorty", minLength=2, maxLength=4, content="1", required=True)
     report = ValidationReport()
     element.validate(report)
     self.assertFalse(report.is_document_valid())
     self.assertEqual("Field shorty is too short. Found 1 characters, expected 2 characters.",
                      report.error_list[0].msg)
示例#2
0
 def test_is_valid_too_long(self):
     """Test an element that's content is too long"""
     element = Element(name="longer", minLength=2, maxLength=4, content="12345", required=True)
     report = ValidationReport()
     element.validate(report)
     self.assertFalse(report.is_document_valid())
     self.assertEqual("Field longer is too long. Found 5 characters, expected 4 characters.",
                      report.error_list[0].msg)
 def test_mismatch_control_id(self):
     transaction = copy.copy(self.transaction_set)
     transaction.header.st02.content = "000000004"
     report = ValidationReport()
     transaction.validate(report)
     self.assertFalse(report.is_document_valid())
     self.assertEqual("The Transaction Set Control Number in ST02 does not match Transaction Set Control Number in SE02",
                      report.error_list[0].msg)
示例#4
0
 def test_gs_04_validation_segment_too_long(self):
     """Test the gs03 segment is too long"""
     test_header = copy.copy(self.header)
     test_header.gs04.content="123456789"
     report = ValidationReport()
     test_header.validate(report)
     self.assertFalse(report.is_document_valid())
     self.assertEqual(self.field_count_string("GS04", "long", 9, 8), report.error_list[0].msg)
     self.assertEqual("GS04", report.error_list[0].segment.name)
示例#5
0
 def test_isa_08_validation_segment_too_long(self):
     """Test the isa08 segment is too long"""
     header = copy.copy(self.int_header)
     header.isa08.content="8005555678BB    "
     report = ValidationReport()
     header.validate(report)
     self.assertFalse(report.is_document_valid())
     self.assertEqual(report.error_list[0].segment.name, "ISA08")
     self.assertEqual(report.error_list[0].msg, self.field_count_string("ISA08", "long", 16, 15))
示例#6
0
 def test_mismatch_control_id(self):
     transaction = copy.copy(self.transaction_set)
     transaction.header.st02.content = "000000004"
     report = ValidationReport()
     transaction.validate(report)
     self.assertFalse(report.is_document_valid())
     self.assertEqual(
         "The Transaction Set Control Number in ST02 does not match Transaction Set Control Number in SE02",
         report.error_list[0].msg)
示例#7
0
 def test_gs_03_validation_segment_too_short(self):
     """Test the gs03 segment is too short"""
     test_header = copy.copy(self.header)
     test_header.gs03.content="1"
     report = ValidationReport()
     test_header.validate(report)
     self.assertFalse(report.is_document_valid())
     self.assertEqual(self.field_count_string("GS03", "short", 1, 2), report.error_list[0].msg)
     self.assertEqual("GS03", report.error_list[0].segment.name)
示例#8
0
 def test_isa_13_validation_segment_too_short(self):
     """Test the isa13 segment is too short"""
     header = copy.copy(self.int_header)
     header.isa13.content="00003821"
     report = ValidationReport()
     header.validate(report)
     self.assertFalse(report.is_document_valid())
     self.assertEqual(report.error_list[0].segment.name, "ISA13")
     self.assertEqual(report.error_list[0].msg, self.field_count_string("ISA13", "short", 8, 9))
示例#9
0
 def test_isa_06_validation_segment_too_short(self):
     """Test the isa06 segment is too short"""
     header = copy.copy(self.int_header)
     header.isa06.content="8005551234AA  "
     report = ValidationReport()
     header.validate(report)
     self.assertFalse(report.is_document_valid())
     self.assertEqual(report.error_list[0].segment.name, "ISA06")
     self.assertEqual(report.error_list[0].msg, self.field_count_string("ISA06", "short", 14, 15))
示例#10
0
 def test_isa_02_validation_segment_too_short(self):
     """Test the isa01 segment is too short"""
     header = copy.copy(self.int_header)
     header.isa02.content="         "
     report = ValidationReport()
     header.validate(report)
     self.assertFalse(report.is_document_valid())
     self.assertEqual(report.error_list[0].segment.name, "ISA02")
     self.assertEqual(report.error_list[0].msg, self.field_count_string("ISA02", "short", 9, 10))
示例#11
0
 def test_isa_03_validation_segment_too_long(self):
     """Test the isa03 segment is too long"""
     header = copy.copy(self.int_header)
     header.isa03.content="000"
     report = ValidationReport()
     header.validate(report)
     self.assertFalse(report.is_document_valid())
     self.assertEqual(report.error_list[0].segment.name, "ISA03")
     self.assertEqual(report.error_list[0].msg, self.field_count_string("ISA03", "long", 3, 2))
示例#12
0
 def test_validate_optional_invalid(self):
     """Test an element that is optional and empty"""
     element = Element(name="optional",
                       minLength=2,
                       maxLength=4,
                       content="12345",
                       required=False)
     report = ValidationReport()
     element.validate(report)
     self.assertFalse(report.is_document_valid())
示例#13
0
 def test_isa_13_validation_segment_too_short(self):
     """Test the isa13 segment is too short"""
     header = copy.copy(self.int_header)
     header.isa13.content = "00003821"
     report = ValidationReport()
     header.validate(report)
     self.assertFalse(report.is_document_valid())
     self.assertEqual(report.error_list[0].segment.name, "ISA13")
     self.assertEqual(report.error_list[0].msg,
                      self.field_count_string("ISA13", "short", 8, 9))
示例#14
0
 def test_isa_06_validation_segment_too_short(self):
     """Test the isa06 segment is too short"""
     header = copy.copy(self.int_header)
     header.isa06.content = "8005551234AA  "
     report = ValidationReport()
     header.validate(report)
     self.assertFalse(report.is_document_valid())
     self.assertEqual(report.error_list[0].segment.name, "ISA06")
     self.assertEqual(report.error_list[0].msg,
                      self.field_count_string("ISA06", "short", 14, 15))
示例#15
0
 def test_isa_03_validation_segment_too_long(self):
     """Test the isa03 segment is too long"""
     header = copy.copy(self.int_header)
     header.isa03.content = "000"
     report = ValidationReport()
     header.validate(report)
     self.assertFalse(report.is_document_valid())
     self.assertEqual(report.error_list[0].segment.name, "ISA03")
     self.assertEqual(report.error_list[0].msg,
                      self.field_count_string("ISA03", "long", 3, 2))
示例#16
0
 def test_isa_02_validation_segment_too_short(self):
     """Test the isa01 segment is too short"""
     header = copy.copy(self.int_header)
     header.isa02.content = "         "
     report = ValidationReport()
     header.validate(report)
     self.assertFalse(report.is_document_valid())
     self.assertEqual(report.error_list[0].segment.name, "ISA02")
     self.assertEqual(report.error_list[0].msg,
                      self.field_count_string("ISA02", "short", 9, 10))
示例#17
0
 def test_isa_08_validation_segment_too_long(self):
     """Test the isa08 segment is too long"""
     header = copy.copy(self.int_header)
     header.isa08.content = "8005555678BB    "
     report = ValidationReport()
     header.validate(report)
     self.assertFalse(report.is_document_valid())
     self.assertEqual(report.error_list[0].segment.name, "ISA08")
     self.assertEqual(report.error_list[0].msg,
                      self.field_count_string("ISA08", "long", 16, 15))
示例#18
0
 def test_validate(self):
     """Test an element that's content is too long"""
     element = Element(name="just right",
                       minLength=2,
                       maxLength=4,
                       content="123",
                       required=True)
     report = ValidationReport()
     element.validate(report)
     self.assertTrue(report.is_document_valid())
示例#19
0
 def test_group_validate_is_valid(self):
     """Test the group being valid"""
     test_group = copy.copy(self.group)
     test_group.header.gs01.content ="00"
     test_group.header.gs06.content = "123456"
     test_group.trailer.ge01.content = "2"
     test_group.trailer.ge02.content = "123456"
     test_group.transaction_sets = ["1", "2"]
     report = ValidationReport()
     test_group.validate(report)
     self.assertTrue(report.is_document_valid())
 def test_group_validate_is_valid(self):
     """Test the group being valid"""
     test_group = copy.copy(self.group)
     test_group.header.gs01.content = "00"
     test_group.header.gs06.content = "123456"
     test_group.trailer.ge01.content = "2"
     test_group.trailer.ge02.content = "123456"
     test_group.transaction_sets = ["1", "2"]
     report = ValidationReport()
     test_group.validate(report)
     self.assertTrue(report.is_document_valid())
示例#21
0
 def test_group_control_id_mismatch(self):
     """Test the group control ids mismatching"""
     test_group = copy.copy(self.group)
     test_group.header.gs06.content = "12345"
     test_group.trailer.ge01.content = "2"
     test_group.trailer.ge02.content = "123456"
     test_group.transaction_sets = ["1", "2"]
     report = ValidationReport()
     test_group.validate(report)
     self.assertFalse(report.is_document_valid())
     self.assertEqual("The Group Control Number in GS06 does not match Group Control Number in GE02",
                      report.error_list[0].msg)
示例#22
0
 def test_group_transaction_count_error(self):
     """Test the group transaction count error"""
     test_group = copy.copy(self.group)
     test_group.header.gs06.content = "123456"
     test_group.trailer.ge01.content = "1"
     test_group.trailer.ge02.content = "123456"
     test_group.transaction_sets = ["1", "2"]
     report = ValidationReport()
     test_group.validate(report)
     self.assertFalse(report.is_document_valid())
     self.assertEqual("The Number of Transaction Sets in GE01 value of 1 does not match the parsed count of 2",
                      report.error_list[0].msg)
 def test_group_transaction_count_error(self):
     """Test the group transaction count error"""
     test_group = copy.copy(self.group)
     test_group.header.gs06.content = "123456"
     test_group.trailer.ge01.content = "1"
     test_group.trailer.ge02.content = "123456"
     test_group.transaction_sets = ["1", "2"]
     report = ValidationReport()
     test_group.validate(report)
     self.assertFalse(report.is_document_valid())
     self.assertEqual(
         "The Number of Transaction Sets in GE01 value of 1 does not match the parsed count of 2",
         report.error_list[0].msg)
示例#24
0
 def test_is_valid_too_long(self):
     """Test an element that's content is too long"""
     element = Element(name="longer",
                       minLength=2,
                       maxLength=4,
                       content="12345",
                       required=True)
     report = ValidationReport()
     element.validate(report)
     self.assertFalse(report.is_document_valid())
     self.assertEqual(
         "Field longer is too long. Found 5 characters, expected 4 characters.",
         report.error_list[0].msg)
示例#25
0
 def test_is_valid_too_short(self):
     """Test an element that's content is too short"""
     element = Element(name="shorty",
                       minLength=2,
                       maxLength=4,
                       content="1",
                       required=True)
     report = ValidationReport()
     element.validate(report)
     self.assertFalse(report.is_document_valid())
     self.assertEqual(
         "Field shorty is too short. Found 1 characters, expected 2 characters.",
         report.error_list[0].msg)
 def test_group_control_id_mismatch(self):
     """Test the group control ids mismatching"""
     test_group = copy.copy(self.group)
     test_group.header.gs06.content = "12345"
     test_group.trailer.ge01.content = "2"
     test_group.trailer.ge02.content = "123456"
     test_group.transaction_sets = ["1", "2"]
     report = ValidationReport()
     test_group.validate(report)
     self.assertFalse(report.is_document_valid())
     self.assertEqual(
         "The Group Control Number in GS06 does not match Group Control Number in GE02",
         report.error_list[0].msg)
示例#27
0
 def test_validate_is_valid(self):
     envelope = MockEnvelopeWithBody()
     report = ValidationReport()
     envelope.validate(report)
     self.assertTrue(report.is_document_valid())
示例#28
0
 def validate(self):
     """Validate this document and return a validation report"""
     report = ValidationReport()
     self.interchange.validate(report)
     return report
示例#29
0
 def test_validate(self):
     """Test an element that's content is too long"""
     element = Element(name="just right", minLength=2, maxLength=4, content="123", required=True)
     report = ValidationReport()
     element.validate(report)
     self.assertTrue(report.is_document_valid())
示例#30
0
 def test_validate_is_valid(self):
     envelope = MockEnvelopeWithBody()
     report = ValidationReport()
     envelope.validate(report)
     self.assertTrue(report.is_document_valid())
示例#31
0
 def test_validate_optional_invalid(self):
     """Test an element that is optional and empty"""
     element = Element(name="optional", minLength=2, maxLength=4, content="12345", required=False)
     report = ValidationReport()
     element.validate(report)
     self.assertFalse(report.is_document_valid())