Пример #1
0
 def setUp(self):
     self.maxDiff = None  # Allow self.assertMultiLineEqual to show all diffs.
     self.logger = dsrf_logger.DSRFLogger(__name__, '/tmp/example.log',
                                          True)
     self.row_validators_list = {
         'FHEA': [
             cell_validators.StringValidator('RecordType', self.logger,
                                             False),
             cell_validators.StringValidator('MessageId', self.logger,
                                             False),
             cell_validators.IntegerValidator('FileNumber', self.logger,
                                              False),
             cell_validators.IntegerValidator('NumberOfFiles', False, False)
         ],
         'SY03': [
             cell_validators.StringValidator('RecordType', self.logger,
                                             False),
             cell_validators.StringValidator('CommercialModelType',
                                             self.logger, False),
             cell_validators.StringValidator('UseType', self.logger, False),
             cell_validators.StringValidator('Territory', self.logger,
                                             False),
             cell_validators.StringValidator('ServiceDescription',
                                             self.logger, False),
             cell_validators.IntegerValidator('NumberOfUsages', self.logger,
                                              False)
         ],
         'RE01': [
             cell_validators.StringValidator('RecordType', self.logger,
                                             False),
             cell_validators.StringValidator('BlockId', self.logger, False),
             cell_validators.StringValidator('ReleaseReference',
                                             self.logger, False),
             cell_validators.StringValidator('DspReleaseId', self.logger,
                                             False)
         ],
         'AS02': [
             cell_validators.StringValidator('RecordType', self.logger,
                                             False),
             cell_validators.StringValidator('BlockId', self.logger, False),
             cell_validators.StringValidator('ResourceReference',
                                             self.logger, False),
             cell_validators.StringValidator('DspResourceId', self.logger,
                                             False),
             cell_validators.StringValidator('ISRC', self.logger, False),
             cell_validators.StringValidator('Title', self.logger, False)
         ],
         'FFOO': [
             cell_validators.StringValidator('RecordType', self.logger,
                                             False),
             cell_validators.IntegerValidator('NumberOfLines', self.logger,
                                              False)
         ]
     }
     self.expected_blocks = [
         self.block_from_ascii(HEAD_BLOCK),
         self.block_from_ascii(BODY_BLOCK),
         self.block_from_ascii(FOOT_BLOCK)
     ]
Пример #2
0
 def test_get_row_object_invalid(self):
   file_row = ['FFOO', '123a']
   row_validators = {
       'FFOO': [
           cell_validators.StringValidator('RecordType', self.logger, False),
           cell_validators.IntegerValidator(
               'NumberOfLines', self.logger, False)]}
   parser = self._get_file_parser(row_validators)
   with six.assertRaisesRegex(
       self, error.CellValidationFailure,
       r'Cell "NumberOfLines" contains invalid value "123a". Value was '
       r'expected to be an integer. \[Block: 1, Row: 8, file=filename\]'):
     parser.get_row_object(file_row, 'FFOO', 8, 1)
Пример #3
0
 def test_parse_xsd_file_valid_row_types_in_a_specific_row(self):
     """Tests the expected cells in a specific row."""
     rows_validators = self.dsrf_schema_parser.parse_xsd_file(self.logger)
     expected_su02_validators = [
         cell_validators.FixedStringValidator({}, 'RecordType', self.logger,
                                              True, False),
         cell_validators.StringValidator('BlockId', self.logger, True,
                                         False),
         cell_validators.StringValidator('SalesTransactionId', self.logger,
                                         True, False),
         cell_validators.StringValidator('TransactedReleaseOrResource',
                                         self.logger, True, False),
         cell_validators.StringValidator('CommercialModelType', self.logger,
                                         True, False),
         cell_validators.FixedStringValidator({}, 'UseType', self.logger,
                                              True, False),
         cell_validators.StringValidator('Territory', self.logger, True,
                                         False),
         cell_validators.StringValidator('ServiceDescription', self.logger,
                                         False, False),
         cell_validators.BooleanValidator('IsRoyaltyBearing', self.logger,
                                          True, False),
         cell_validators.IntegerValidator('NumberOfStreams', self.logger,
                                          True, False),
         cell_validators.StringValidator('Currency', self.logger, False,
                                         False),
         cell_validators.DecimalValidator('PriceConsumerPaidExcSalesTax',
                                          self.logger, False, False),
         cell_validators.StringValidator('PromotionalActivity', self.logger,
                                         False, False),
         cell_validators.BooleanValidator('PreviewAvailable', self.logger,
                                          False, False),
     ]
     for actual_cell, expected_cell in zip(rows_validators['SU02'],
                                           expected_su02_validators):
         self.assertIsInstance(actual_cell, expected_cell.__class__)
         self.assertEquals(actual_cell.cell_name, expected_cell.cell_name,
                           self.logger)
         self.assertEquals(actual_cell.required, expected_cell.required)
         self.assertEquals(actual_cell.repeated, expected_cell.repeated)
Пример #4
0
 def get_validator(self):
   return cell_validators.IntegerValidator('int_cell', self.logger)