Exemple #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')
Exemple #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)
Exemple #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)
Exemple #4
0
	def _get_header(self, data):
		"""Parses the given data to generate the simple section header
		
		Private method used to generate the first level header.
		Arguments:
			data -- array section data bytes long enough to describe the entire section header
		Returns:
			The byte offset at which the header ends and the rest of the section data continues
		"""
		if self.header: return 3
		self.table_id                 = sparse.get_table_id(data)
		self.section_syntax_indicator = sparse.get_section_syntax_indicator(data)
		self.private_indicator        = sparse.get_private_indicator(data)
		self.section_length           = sparse.get_section_length(data)
		self.length                   = self.section_length + 3
		self.header                   = True
		return 3
Exemple #5
0
    def _get_header(self, data):
        """Parses the given data to generate the simple section header
		
		Private method used to generate the first level header.
		Arguments:
			data -- array section data bytes long enough to describe the entire section header
		Returns:
			The byte offset at which the header ends and the rest of the section data continues
		"""
        if self.header: return 3
        self.table_id = sparse.get_table_id(data)
        self.section_syntax_indicator = sparse.get_section_syntax_indicator(
            data)
        self.private_indicator = sparse.get_private_indicator(data)
        self.section_length = sparse.get_section_length(data)
        self.length = self.section_length + 3
        self.header = True
        return 3
Exemple #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')