Exemple #1
0
 def setUp(self):
     TEST_FILE.seek(0, 0)
     self.pump = CLBPump()
     self.pump.blob_file = TEST_FILE
Exemple #2
0
class TestCLBPump(TestCase):

    def setUp(self):
        TEST_FILE.seek(0, 0)
        self.pump = CLBPump()
        self.pump.blob_file = TEST_FILE

    def test_determine_packet_positions_finds_packets(self):
        self.pump.determine_packet_positions()
        self.assertListEqual([0, 1406, 2284], self.pump.packet_positions)

    def test_seek_to_packet(self):
        pump = self.pump
        pump.determine_packet_positions()
        pump.seek_to_packet(2)
        self.assertEqual(2284, pump.blob_file.tell())
        pump.seek_to_packet(1)
        self.assertEqual(1406, pump.blob_file.tell())

    def test_get_blob(self):
        self.pump.determine_packet_positions()
        blob = self.pump.get_blob(0)
        self.assertEqual(0, blob['CLBHeader'].run_number)
        self.assertEqual('TTDC', blob['CLBHeader'].data_type)
        self.assertEqual(229, len(blob['PMTData']))
        a_pmt_data = blob['PMTData'][0]
        self.assertEqual(0, a_pmt_data.channel_id)
        self.assertEqual(66254747, a_pmt_data.timestamp)
        self.assertEqual(12, a_pmt_data.tot)

    def test_next_blob(self):
        self.pump.determine_packet_positions()
        blob = self.pump.next_blob()
        self.assertEqual(229, len(blob['PMTData']))
        blob = self.pump.next_blob()
        self.assertEqual(141, len(blob['PMTData']))
        blob = self.pump.next_blob()
        self.assertEqual(229, len(blob['PMTData']))

    def test_next_blob_raises_stop_iteration_on_eof(self):
        self.pump.determine_packet_positions()
        self.pump.next_blob()
        self.pump.next_blob()
        self.pump.next_blob()
        self.assertRaises(StopIteration, self.pump.next_blob)