Пример #1
0
 def test_emit_document(self):
     data = 'test'
     node = MagicMock(spec=IProducerNode)
     node.provides.return_value = six.text_type
     test_time = timedelta(hours=42,
                           minutes=42,
                           seconds=42,
                           milliseconds=67)
     node.resume_producing.side_effect = EndOfData()
     fs_carriage = FilesystemProducerImpl(self.test_dir_path)
     fs_carriage.register_producer_node(node)
     fs_carriage.resume_producing()
     fs_carriage.emit_data(data,
                           availability_time=test_time,
                           sequence_identifier='testSeq',
                           sequence_number=1,
                           time_base='clock',
                           clock_mode='local')
     exported_document_path = os.path.join(self.test_dir_path,
                                           'testSeq_1.xml')
     assert os.path.exists(exported_document_path)
     manifest_path = os.path.join(self.test_dir_path,
                                  'manifest_testSeq.txt')
     assert os.path.exists(manifest_path)
     assert fs_carriage._default_clocks == {}
 def test_resume_producing_no_existing_manifest(self, node):
     fs_carriage = FilesystemProducerImpl(self.test_dir_path)
     node.process_document = MagicMock(side_effect=EndOfData())
     node.document_sequence.sequence_identifier = "testSeq"
     fs_carriage.register(node)
     fs_carriage.resume_producing()
     assert node.process_document.called
 def test_resume_producing_existing_manifest(self, node):
     manifest_path = os.path.join(self.test_dir_path, "manifest_testSeq.txt")
     with open(manifest_path, 'w') as f:
         f.write("00:00:00.123678,testSeq_177.xml")
     fs_carriage = FilesystemProducerImpl(self.test_dir_path)
     node.process_document = MagicMock(side_effect=EndOfData())
     node.document_sequence.sequence_identifier = "testSeq"
     fs_carriage.register(node)
     fs_carriage.resume_producing()
     assert node.process_document.called
     self.assertEqual(node.document_sequence.last_sequence_number, 177)
    def process_document(self, document):

        activation_time = self._reference_clock.get_time() + timedelta(seconds=1)

        if self._input_blocks:
            try:
                lines = self._input_blocks.next()
            except StopIteration:
                raise EndOfData(END_OF_DATA)
        else:
            lines = [LimitedClockTimingType(activation_time)]

        document = self._document_sequence.new_document()

        # Add default style
        document.binding.head.styling = styling(
            style_type(
                id='defaultStyle1',
                backgroundColor="rgb(0, 0, 0)",
                color="rgb(255, 255, 255)",
                linePadding="0.5c",
                fontFamily="sansSerif"
            )
        )
        document.binding.head.layout = layout(
            region_type(
                id='bottomRegion',
                origin='14.375% 60%',
                extent='71.25% 24%',
                displayAlign='after',
                writingMode='lrtb',
                overflow="visible"
            )
        )
        document.add_div(
            self._create_fragment(
                lines,
                'defaultStyle1'
            ),
        )

        document.set_dur(LimitedClockTimingType(timedelta(seconds=1)))
        document.set_begin(LimitedClockTimingType(activation_time))

        document.validate()

        self._carriage_impl.emit_document(document)
 def test_emit_document(self):
     document = MagicMock(sequence_identifier="testSeq", sequence_number=1)
     document.get_xml = MagicMock(return_value="test")
     node = MagicMock()
     test_time = timedelta(hours=42, minutes=42, seconds=42, milliseconds=67)
     node.reference_clock.get_time.return_value = test_time
     node.process_document = MagicMock(side_effect=EndOfData())
     node.document_sequence.sequence_identifier = "testSeq"
     node.reference_clock.time_base = "clock"
     fs_carriage = FilesystemProducerImpl(self.test_dir_path)
     fs_carriage.register(node)
     fs_carriage.resume_producing()
     fs_carriage.emit_document(document)
     exported_document_path = os.path.join(self.test_dir_path, 'testSeq_1.xml')
     assert os.path.exists(exported_document_path)
     manifest_path = os.path.join(self.test_dir_path, 'manifest_testSeq.txt')
     assert os.path.exists(manifest_path)
Пример #6
0
 def side_effect():
     raise EndOfData()