Beispiel #1
0
    class PartialData(unittest.TestCase):
        nit_data_0 = _known_tables.get_sample_nit_data()[0]

        def setUp(self):
            self.section = Section()

        def testPartialData1(self):
            for i in range(0, len(nit_data_0)):
                #print list([nit_data_0[i]])
                self.section.add_data(list([nit_data_0[i]]))
            test_nit_0(self, self.section)

        def testPartialData2(self):
            for i in range(0, len(nit_data_0), 2):
                self.section.add_data(list(nit_data_0[i:i + 2]))
            test_nit_0(self, self.section)

        def testPartialData3(self):
            for i in range(0, len(nit_data_0), 3):
                self.section.add_data(list(nit_data_0[i:i + 3]))
            test_nit_0(self, self.section)

        def testPartialData4(self):
            for i in range(0, len(nit_data_0), 4):
                self.section.add_data(list(nit_data_0[i:i + 4]))
            test_nit_0(self, self.section)
Beispiel #2
0
            res += '\tSection Number     [%d]\n' % (self.section_number)
            res += '\tLast Section Number[%d]\n' % (self.last_section_number)
            if self.complete:
                res += '\tCRC[0x%x]\n' % (self.crc)
        return res


'''UNIT TESTS -------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------
'''
if __name__ == '__main__':
    #TODO - not a full unit test - need to do partial data addition
    import unittest
    import _known_tables

    nit_data_0 = _known_tables.get_sample_nit_data()[0]
    nit_data_1 = _known_tables.get_sample_nit_data()[1]
    cat_data = _known_tables.get_sample_cat_data()[0]
    pat_data = _known_tables.get_sample_pat_data()[0]
    pmt_data = _known_tables.get_sample_pmt_data()[0]

    def testNitSection0(test_case, section):
        test_case.assertEqual(64, section.table_id, 'incorrect table id')
        test_case.assertEqual(True, section.section_syntax_indicator,
                              'incorrect section syntax indicator')
        test_case.assertEqual(True, section.private_indicator,
                              'incorrect private section indicator')
        test_case.assertEqual(1014, section.section_length,
                              'incorrect section length')
        test_case.assertEqual(6144, section.table_id_extension,
                              'incorrect table id extension')
Beispiel #3
0
			res += '\tSection Number     [%d]\n'%(self.section_number)
			res += '\tLast Section Number[%d]\n'%(self.last_section_number)
			if self.complete:
				res += '\tCRC[0x%x]\n'%(self.crc)
		return res
	

'''UNIT TESTS -------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------
'''
if __name__ == '__main__':
	#TODO - not a full unit test - need to do partial data addition
	import unittest
	import _known_tables

	nit_data_0 = _known_tables.get_sample_nit_data()[0]
	nit_data_1 = _known_tables.get_sample_nit_data()[1]
	cat_data   = _known_tables.get_sample_cat_data()[0]
	pat_data   = _known_tables.get_sample_pat_data()[0]
	pmt_data   = _known_tables.get_sample_pmt_data()[0]
	
	def testNitSection0(test_case, section):
		test_case.assertEqual(64, section.table_id, 'incorrect table id')
		test_case.assertEqual(True, section.section_syntax_indicator, 'incorrect section syntax indicator')
		test_case.assertEqual(True, section.private_indicator, 'incorrect private section indicator')
		test_case.assertEqual(1014, section.section_length, 'incorrect section length')
		test_case.assertEqual(6144, section.table_id_extension, 'incorrect table id extension')
		test_case.assertEqual(1, section.version, 'incorrect version')
		test_case.assertEqual(0, section.section_number, 'incorrect section number')
		test_case.assertEqual(1, section.last_section_number, 'incorrect last section number')
		test_case.assertEqual(section.section_length, len(section.table_body), 'table body has incorrect length')