def test_is_equal_dom(self):
     xml = ""
     file_path = os.path.join(os.path.dirname(__file__), 'data',
                              'document.xml')
     with open(file_path) as xml_file:
         xml = xml_file.read()
     document1 = EBUTT3Document.create_from_xml(xml)
     document2 = EBUTT3Document.create_from_xml(xml)
     self.assertTrue(compare_xml(document1.get_xml(), document2.get_xml()))
     document2 = EBUTT3Document.create_from_xml(xml.replace('500', '3500'))
     self.assertFalse(compare_xml(document2.get_xml(), document1.get_xml()))
Example #2
0
    def __init__(self,
                 node_id,
                 reference_clock,
                 segment_length,
                 discard,
                 sequence_identifier,
                 consumer_carriage=None,
                 producer_carriage=None,
                 init_document=None,
                 **kwargs):
        super(ReSequencer, self).__init__(node_id=node_id,
                                          consumer_carriage=consumer_carriage,
                                          producer_carriage=producer_carriage,
                                          reference_clock=reference_clock,
                                          **kwargs)
        self._last_segment_end = reference_clock.get_time()
        self._segment_length = timedelta(seconds=segment_length)
        # self._segment_timer = segment_timer
        self._segment_counter = 1
        self._sequence_identifier = sequence_identifier
        self._discard = discard

        if init_document is not None:
            # Create sequence from init document, in order to immediately start document output
            log.info('Creating document sequence from init document {}'.format(
                init_document))
            with open(init_document, 'r') as xml_file:
                xml_content = xml_file.read()
            xml_doc = EBUTT3Document.create_from_xml(xml_content)
            self.create_sequence_from_document(xml_doc)
Example #3
0
def when_range_requested(template_file, test_context, template_dict,
                         range_from, range_to):
    xml_file = template_file.render(template_dict)
    document = EBUTT3Document.create_from_xml(xml_file)
    fragment = document.extract_segment(
        FullClockTimingType(range_from).timedelta,
        FullClockTimingType(range_to).timedelta)
    test_context['fragment'] = fragment
def when_range_requested(template_file, test_context, template_dict, range_from, range_to):
    xml_file = template_file.render(template_dict)
    document = EBUTT3Document.create_from_xml(xml_file)
    fragment = document.extract_segment(
        FullClockTimingType(range_from).timedelta,
        FullClockTimingType(range_to).timedelta
    )
    test_context['fragment'] = fragment
Example #5
0
def when_doc3_added_to_seq(doc3_avail_time, template_file, template_dict,
                           sequence, test_context):
    xml_file = template_file.render(template_dict)
    document = EBUTT3Document.create_from_xml(xml_file)
    document.availability_time = timestr_to_timedelta(
        doc3_avail_time, sequence.reference_clock.time_base)
    sequence.add_document(document)
    test_context['doc3'] = document
    def _create_test_document(self):
        doc = EBUTT3Document(time_base='clock',
                             clock_mode='local',
                             lang='en-GB',
                             sequence_identifier='testSequenceEncoder01',
                             sequence_number='1')

        head_elem = bindings.head_type(
            metadata.headMetadata_type(metadata.documentMetadata()),
            bindings.styling(
                bindings.style_type(id='style1', fontSize='12px'),
                bindings.style_type(id='style2', fontSize='15px'),
                bindings.style_type(id='style3', color='red', fontSize='12px'),
                bindings.style_type(id='style4', backgroundColor='blue')),
            bindings.layout(
                bindings.region_type(id='region1',
                                     origin='200px 450px',
                                     extent='300px 150px',
                                     style=['style3'])))

        body_elem = bindings.body_type(bindings.div_type(bindings.p_type(
            bindings.span_type('Some example text...',
                               begin=datatypes.LimitedClockTimingType(
                                   timedelta(hours=11, minutes=32, seconds=1)),
                               end=datatypes.LimitedClockTimingType(
                                   timedelta(hours=11, minutes=32, seconds=2)),
                               style=['style4'],
                               id='span1'),
            bindings.br_type(),
            bindings.span_type('And another line',
                               begin=datatypes.LimitedClockTimingType(
                                   timedelta(hours=11, minutes=32, seconds=3)),
                               end=datatypes.LimitedClockTimingType(
                                   timedelta(hours=11, minutes=32, seconds=4)),
                               id='span2'),
            id='ID005',
        ),
                                                         style=['style1'],
                                                         region='region1'),
                                       begin=datatypes.LimitedClockTimingType(
                                           timedelta(hours=11,
                                                     minutes=32,
                                                     seconds=.5)),
                                       dur=datatypes.LimitedClockTimingType(
                                           timedelta(hours=11,
                                                     minutes=32,
                                                     seconds=5)),
                                       style=['style2'])

        doc.binding.head = head_elem
        doc.binding.body = body_elem
        doc.binding.extent = '800px 600px'
        doc.validate()
        raw_xml = doc.get_xml()
        doc = EBUTT3Document.create_from_xml(raw_xml)
        return doc
def main():
    create_loggers()
    log.info('Let\'s get started')
    args = parser.parse_args()

    if args.input_file:
        with open(args.input_file, 'r') as ifile:
            document = EBUTT3Document.create_from_xml(ifile.read())

    import ipdb
    ipdb.set_trace()
def main():
    create_loggers()
    log.info('Let\'s get started')
    args = parser.parse_args()

    if args.input_file:
        with open(args.input_file, 'r') as ifile:
            document = EBUTT3Document.create_from_xml(ifile.read())

    import ipdb
    ipdb.set_trace()
Example #9
0
    def _generate_document(self, sequence_number=1, offset=None):
        # offset is a timedelta object to help generate the timings
        if offset is None:
            offset = timedelta()

        # template_file = self._j2env.get_template('mem_prof_document.xml')
        template_file = Template(raw_template)
        temp_dict = {
            'sequence_number': sequence_number,
            'body_begin': ebuttdt.FullClockTimingType(offset)
        }

        doc = EBUTT3Document.create_from_xml(template_file.render(temp_dict))
        # print 'doc id {} created'.format(id(doc))
        return doc
    def _generate_document(self, sequence_number=1, offset=None):
        # offset is a timedelta object to help generate the timings
        if offset is None:
            offset = timedelta()

        # template_file = self._j2env.get_template('mem_prof_document.xml')
        template_file = Template(raw_template)
        temp_dict = {
            'sequence_number': sequence_number,
            'body_begin': ebuttdt.FullClockTimingType(offset)
        }

        doc = EBUTT3Document.create_from_xml(
            template_file.render(temp_dict)
        )
        # print 'doc id {} created'.format(id(doc))
        return doc
Example #11
0
def invalid_doc(template_file, template_dict):
    xml_file = template_file.render(template_dict)
    with pytest.raises(Exception):
        EBUTT3Document.create_from_xml(xml_file)
Example #12
0
def valid_doc(template_file, template_dict):
    xml_file = template_file.render(template_dict)
    document = EBUTT3Document.create_from_xml(xml_file)
    assert isinstance(document, EBUTT3Document)
def when_doc2_added_to_seq(doc2_avail_time, template_file, template_dict, sequence, test_context):
    xml_file = template_file.render(template_dict)
    document = EBUTT3Document.create_from_xml(xml_file)
    document.availability_time = timestr_to_timedelta(doc2_avail_time, sequence.reference_clock.time_base)
    sequence.add_document(document)
    test_context['doc2'] = document
def when_doc1_added_to_sequence(doc_list, template_file, template_dict):
    xml_file = template_file.render(template_dict)
    document = EBUTT3Document.create_from_xml(xml_file)
    doc_list.append(document)
def then_adding_doc2_success(doc_list, template_file, template_dict):
    xml_file = template_file.render(template_dict)
    document = EBUTT3Document.create_from_xml(xml_file)
    sequence = EBUTT3DocumentSequence.create_from_document(doc_list[0])
    sequence.add_document(document)
def then_adding_doc2_error(doc_list, template_file, template_dict):
    xml_file = template_file.render(template_dict)
    document = EBUTT3Document.create_from_xml(xml_file)
    sequence = EBUTT3DocumentSequence.create_from_document(doc_list[0])
    with pytest.raises(Exception):
        sequence.add_document(document)
Example #17
0
def gen_first_document(test_context, template_dict, template_file_one):
    xml_file_1 = template_file_one.render(template_dict)
    document1 = EBUTT3Document.create_from_xml(xml_file_1)
    test_context['document1'] = document1
    document1.validate()
    return document1
Example #18
0
def valid_doc(template_file_two, template_dict):
    xml_file_2 = template_file_two.render(template_dict)
    document = EBUTT3Document.create_from_xml(xml_file_2)
    assert isinstance(document, EBUTT3Document)
Example #19
0
def gen_document(template_file, template_dict):
    # TODO: This is legacy and to be removed when tests are refactored
    xml_file = template_file.render(template_dict)
    document = EBUTT3Document.create_from_xml(xml_file)
    document.validate()
    return document
def gen_document(template_file, template_dict):
    xml_file = template_file.render(template_dict)
    document = EBUTT3Document.create_from_xml(xml_file)
    document.validate()
    return document
def when_doc_generated(test_context, template_dict, template_file):
    xml_file = template_file.render(template_dict)
    document = EBUTT3Document.create_from_xml(xml_file)
    test_context['document'] = document
def when_doc_added_to_sequence(template_file, template_dict, sequence):
    xml_file = template_file.render(template_dict)
    document = EBUTT3Document.create_from_xml(xml_file)
    sequence.add_document(document)
Example #23
0
def gen_document(template_file, template_dict):
    xml_file = template_file.render(template_dict)
    document = EBUTT3Document.create_from_xml(xml_file)
    document.validate()
    return document
def when_processes_document(distributing_node, test_context, template_file):
    xml_file = template_file.render()
    test_context['document'] = xml_file
    distributing_node.process_document(EBUTT3Document.create_from_xml(xml_file), raw_xml=xml_file)
Example #25
0
def when_doc_added_to_sequence(template_file, template_dict, sequence):
    xml_file = template_file.render(template_dict)
    document = EBUTT3Document.create_from_xml(xml_file)
    sequence.add_document(document)
Example #26
0
def when_doc_generated(test_context, template_dict, template_file):
    xml_file = template_file.render(template_dict)
    document = EBUTT3Document.create_from_xml(xml_file)
    test_context['document'] = document
Example #27
0
def gen_second_document(test_context, template_dict, template_file_two):
    xml_file_2 = template_file_two.render(template_dict)
    document2 = EBUTT3Document.create_from_xml(xml_file_2)
    test_context['document2'] = document2
    document2.validate()
    return document2
def check_correct_parsing(template_file, template_dict, trusted_timedeltas_index):
    xml_file = template_file.render(template_dict)
    document = EBUTT3Document.create_from_xml(xml_file)
    assert document._ebutt3_content.body.begin.timedelta == trusted_timedeltas[trusted_timedeltas_index]
Example #29
0
def invalid_doc(template_file, template_dict):
    xml_file = template_file.render(template_dict)
    with pytest.raises(Exception):
        EBUTT3Document.create_from_xml(xml_file)
def then_adding_doc2_error(doc_list, template_file, template_dict):
    xml_file = template_file.render(template_dict)
    document = EBUTT3Document.create_from_xml(xml_file)
    sequence = EBUTT3DocumentSequence.create_from_document(doc_list[0])
    with pytest.raises(Exception):
        sequence.add_document(document)
Example #31
0
def when_doc_generated(test_context, template_dict, template_file):
    # This is a more standard-compliant way to do this
    xml_file = template_file.render(template_dict)
    document = EBUTT3Document.create_from_xml(xml_file)
    test_context['document'] = document
def then_adding_doc2_success(doc_list, template_file, template_dict):
    xml_file = template_file.render(template_dict)
    document = EBUTT3Document.create_from_xml(xml_file)
    sequence = EBUTT3DocumentSequence.create_from_document(doc_list[0])
    sequence.add_document(document)
Example #33
0
def check_correct_parsing(template_file, template_dict,
                          trusted_timedeltas_index):
    xml_file = template_file.render(template_dict)
    document = EBUTT3Document.create_from_xml(xml_file)
    assert document._ebutt3_content.body.begin.timedelta == trusted_timedeltas[
        trusted_timedeltas_index]
def when_doc1_added_to_sequence(doc_list, template_file, template_dict):
    xml_file = template_file.render(template_dict)
    document = EBUTT3Document.create_from_xml(xml_file)
    doc_list.append(document)