Пример #1
0
		def test(self):
			self.assertEqual(len(self.data), self.data_length)
			set_table_id(self.data, 1)
			self.assertEqual(self.data[0], 1, 'error setting table id')
			set_section_syntax_indicator(self.data, True)
			self.assertTrue(sparser.get_section_syntax_indicator(self.data), 'Error setting section syntax indicator')
			set_section_syntax_indicator(self.data, False)
			self.assertFalse(sparser.get_section_syntax_indicator(self.data), 'Error setting section syntax indicator')
			set_section_syntax_indicator(self.data, True)
			self.assertTrue(sparser.get_section_syntax_indicator(self.data), 'Error setting section syntax indicator')
			set_private_indicator(self.data, False)
			self.assertFalse(sparser.get_private_indicator(self.data), 'Error setting private indicator')
			set_section_length(self.data, self.data_length - 3)
			self.assertEqual(sparser.get_section_length(self.data), self.data_length-3, 'error setting section length')
			set_table_id_extension(self.data, 20)
			self.assertEqual(sparser.get_table_id_extension(self.data), 20, 'error setting table id extension')
			set_version_number(self.data, 10)
			self.assertEqual(sparser.get_version_number(self.data), 10, 'error setting version number')
			set_current_next_indicator(self.data, True)
			self.assertTrue(sparser.get_current_next_indicator(self.data), 'Error setting current next indicator')
			set_section_number(self.data, 25)
			self.assertEqual(sparser.get_section_number(self.data), 25, 'error setting section number')
			set_last_section_number(self.data, 35)
			self.assertEqual(sparser.get_last_section_number(self.data), 35, 'error setting last section number')
			self.data_contents = random.sample(range(256), self.data_length-8)
			actual_data_contents = sparser.get_data(self.data)
			set_data(self.data, self.data_contents, 8)
			actual_data_contents = sparser.get_data(self.data)
			self.assertEqual(actual_data_contents, self.data_contents, 'error setting section data')
Пример #2
0
		def test(self):
			self.data_contents = random.sample(range(256), self.data_length-8)
			set_data(self.data, self.data_contents, 8)
			set_last_section_number(self.data, 35)
			set_section_number(self.data, 25)
			set_current_next_indicator(self.data, True)
			set_version_number(self.data, 10)
			set_table_id_extension(self.data, 20)
			set_section_length(self.data, self.data_length - 3)
			set_private_indicator(self.data, False)
			set_section_syntax_indicator(self.data, True)
			set_table_id(self.data, 1)
			
			self.assertEqual(len(self.data), self.data_length)
			self.assertEqual(self.data[0], 1)
			self.assertTrue(sparser.get_section_syntax_indicator(self.data))
			self.assertFalse(sparser.get_private_indicator(self.data))
			self.assertEqual(sparser.get_section_length(self.data), self.data_length-3)
			self.assertEqual(sparser.get_table_id_extension(self.data), 20)
			self.assertEqual(sparser.get_version_number(self.data), 10)
			self.assertTrue(sparser.get_current_next_indicator(self.data))
			self.assertEqual(sparser.get_section_number(self.data), 25)
			self.assertEqual(sparser.get_last_section_number(self.data), 35)
			actual_data_contents = sparser.get_data(self.data)
			self.assertEqual(actual_data_contents, self.data_contents)
Пример #3
0
        def test(self):
            self.data_contents = random.sample(range(256),
                                               self.data_length - 8)
            set_data(self.data, self.data_contents, 8)
            set_last_section_number(self.data, 35)
            set_section_number(self.data, 25)
            set_current_next_indicator(self.data, True)
            set_version_number(self.data, 10)
            set_table_id_extension(self.data, 20)
            set_section_length(self.data, self.data_length - 3)
            set_private_indicator(self.data, False)
            set_section_syntax_indicator(self.data, True)
            set_table_id(self.data, 1)

            self.assertEqual(len(self.data), self.data_length)
            self.assertEqual(self.data[0], 1)
            self.assertTrue(sparser.get_section_syntax_indicator(self.data))
            self.assertFalse(sparser.get_private_indicator(self.data))
            self.assertEqual(sparser.get_section_length(self.data),
                             self.data_length - 3)
            self.assertEqual(sparser.get_table_id_extension(self.data), 20)
            self.assertEqual(sparser.get_version_number(self.data), 10)
            self.assertTrue(sparser.get_current_next_indicator(self.data))
            self.assertEqual(sparser.get_section_number(self.data), 25)
            self.assertEqual(sparser.get_last_section_number(self.data), 35)
            actual_data_contents = sparser.get_data(self.data)
            self.assertEqual(actual_data_contents, self.data_contents)
Пример #4
0
    def _get_extended_header(self, data):
        """Parses the given data to generate the extended section header
		
		Private method called if the table is an extended one (section syntax indicator == 1).
		fills in the extended header information for this object.
		Arguments:
			data -- array of section data bytes, from beginning of section, long enough to describe
			the simple and extended headers.
		Returns:
			The byte offset at which the extended header ends and the rest of the section data continues
		"""
        if self.extended_header: return 5
        self.table_id_extension = sparse.get_table_id_extension(data)
        self.version = sparse.get_version_number(data)
        self.current_next_indicator = sparse.get_current_next_indicator(data)
        self.section_number = sparse.get_section_number(data)
        self.last_section_number = sparse.get_last_section_number(data)
        self.extended_header = True
        return 5
Пример #5
0
	def _get_extended_header(self, data):
		"""Parses the given data to generate the extended section header
		
		Private method called if the table is an extended one (section syntax indicator == 1).
		fills in the extended header information for this object.
		Arguments:
			data -- array of section data bytes, from beginning of section, long enough to describe
			the simple and extended headers.
		Returns:
			The byte offset at which the extended header ends and the rest of the section data continues
		"""
		if self.extended_header: return 5
		self.table_id_extension     = sparse.get_table_id_extension(data)
		self.version                = sparse.get_version_number(data)
		self.current_next_indicator = sparse.get_current_next_indicator(data)
		self.section_number         = sparse.get_section_number(data)
		self.last_section_number    = sparse.get_last_section_number(data)
		self.extended_header        = True
		return 5
Пример #6
0
 def test(self):
     self.assertEqual(len(self.data), self.data_length)
     set_table_id(self.data, 1)
     self.assertEqual(self.data[0], 1, 'error setting table id')
     set_section_syntax_indicator(self.data, True)
     self.assertTrue(sparser.get_section_syntax_indicator(self.data),
                     'Error setting section syntax indicator')
     set_section_syntax_indicator(self.data, False)
     self.assertFalse(sparser.get_section_syntax_indicator(self.data),
                      'Error setting section syntax indicator')
     set_section_syntax_indicator(self.data, True)
     self.assertTrue(sparser.get_section_syntax_indicator(self.data),
                     'Error setting section syntax indicator')
     set_private_indicator(self.data, False)
     self.assertFalse(sparser.get_private_indicator(self.data),
                      'Error setting private indicator')
     set_section_length(self.data, self.data_length - 3)
     self.assertEqual(sparser.get_section_length(self.data),
                      self.data_length - 3,
                      'error setting section length')
     set_table_id_extension(self.data, 20)
     self.assertEqual(sparser.get_table_id_extension(self.data), 20,
                      'error setting table id extension')
     set_version_number(self.data, 10)
     self.assertEqual(sparser.get_version_number(self.data), 10,
                      'error setting version number')
     set_current_next_indicator(self.data, True)
     self.assertTrue(sparser.get_current_next_indicator(self.data),
                     'Error setting current next indicator')
     set_section_number(self.data, 25)
     self.assertEqual(sparser.get_section_number(self.data), 25,
                      'error setting section number')
     set_last_section_number(self.data, 35)
     self.assertEqual(sparser.get_last_section_number(self.data), 35,
                      'error setting last section number')
     self.data_contents = random.sample(range(256),
                                        self.data_length - 8)
     actual_data_contents = sparser.get_data(self.data)
     set_data(self.data, self.data_contents, 8)
     actual_data_contents = sparser.get_data(self.data)
     self.assertEqual(actual_data_contents, self.data_contents,
                      'error setting section data')