コード例 #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 == {}
コード例 #2
0
 def test_msg_first_item_missing_availability(self):
     data = 'live message without availability time'
     node = MagicMock(spec=IProducerNode)
     node.provides.return_value = six.text_type
     fs_carriage = FilesystemProducerImpl(self.test_dir_path)
     fs_carriage.register_producer_node(node)
     fs_carriage.emit_data(data, sequence_identifier='testSeq')
     # Expected behaviour is to write the message file but fail to write the manifest.
     assert os.listdir(self.test_dir_path) == ['testSeq_msg_1.xml']
     assert fs_carriage._default_clocks == {}
コード例 #3
0
 def test_doc_missing_availability(self):
     data = 'test document without availability time'
     node = MagicMock(spec=IProducerNode)
     node.provides.return_value = six.text_type
     fs_carriage = FilesystemProducerImpl(self.test_dir_path)
     fs_carriage.register_producer_node(node)
     fs_carriage.emit_data(data,
                           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 isinstance(fs_carriage._default_clocks['testSeq'], Clock)
コード例 #4
0
    def test_msg_mid_sequence_partial_missing_availability(self):
        # This is a quirky edge case that should never really happen
        # An acceptable workaround could be to take the the last received availability time - local clock
        # offset for the sequence and compute an estimate using the local clock
        #
        # Since this was not a requirement the message gets discarded...
        #
        # There are also an unsettling number of odd defined/not defined combinations of arguments at this
        # level, none of which is specified to trigger a particular response: such as receiving
        # availability_time but no time_base...etc.

        node = MagicMock(spec=IProducerNode)
        node.provides.return_value = six.text_type
        fs_carriage = FilesystemProducerImpl(self.test_dir_path)
        fs_carriage.register_producer_node(node)
        test_time = timedelta(hours=42,
                              minutes=42,
                              seconds=42,
                              milliseconds=67)
        data = 'document with availability'
        fs_carriage.emit_data(data,
                              sequence_identifier='testSeq',
                              availability_time=test_time,
                              sequence_number=1,
                              time_base='clock',
                              clock_mode='local')
        data = 'live message without availability time'
        # This message does not have enough information to produce a reference clock by itself
        fs_carriage.emit_data(data, sequence_identifier='testSeq')
        assert len(os.listdir(
            self.test_dir_path)) == 3  # document, message and manifest
        exported_document_path = os.path.join(self.test_dir_path,
                                              'testSeq_1.xml')
        assert os.path.exists(exported_document_path)
        exported_message_path = os.path.join(self.test_dir_path,
                                             'testSeq_msg_1.xml')
        assert os.path.exists(exported_message_path)
        manifest_path = os.path.join(self.test_dir_path,
                                     'manifest_testSeq.txt')
        assert os.path.exists(manifest_path)
コード例 #5
0
 def test_msg_mid_sequence_missing_availability(self):
     node = MagicMock(spec=IProducerNode)
     node.provides.return_value = six.text_type
     fs_carriage = FilesystemProducerImpl(self.test_dir_path)
     fs_carriage.register_producer_node(node)
     data = 'document without availability'
     fs_carriage.emit_data(data,
                           sequence_identifier='testSeq',
                           sequence_number=1,
                           time_base='clock',
                           clock_mode='local')
     data = 'live message without availability time'
     fs_carriage.emit_data(data, sequence_identifier='testSeq')
     assert len(os.listdir(
         self.test_dir_path)) == 3  # document, message and manifest
     exported_document_path = os.path.join(self.test_dir_path,
                                           'testSeq_1.xml')
     assert os.path.exists(exported_document_path)
     exported_message_path = os.path.join(self.test_dir_path,
                                          'testSeq_msg_1.xml')
     assert os.path.exists(exported_message_path)
     manifest_path = os.path.join(self.test_dir_path,
                                  'manifest_testSeq.txt')
     assert os.path.exists(manifest_path)