Пример #1
0
    def test_only_the_custom_region_is_created(self):
        caption_set = DFXPReader().read(
            SAMPLE_DFXP_TO_RENDER_WITH_ONLY_DEFAULT_POSITIONING_INPUT)

        new_region = Layout(
            alignment=Alignment(
                HorizontalAlignmentEnum.LEFT, VerticalAlignmentEnum.TOP
            )
        )

        dfxp = SinglePositioningDFXPWriter(new_region).write(caption_set)
        # Using a different parser, because this preserves letter case
        # The output file is ok, but when parsing it, the "regular" parses
        # loses letter case.
        layout = BeautifulSoup(dfxp, features='xml').findChild('layout')

        self.assertEqual(len(layout.findChildren('region')), 1)

        region = layout.findChild('region')
        text_align = region['tts:textAlign']
        display_align = region['tts:displayAlign']

        internal_alignment = _create_internal_alignment(text_align, display_align)  # noqa
        self.assertEqual(internal_alignment.horizontal, HorizontalAlignmentEnum.LEFT)  # noqa
        self.assertEqual(internal_alignment.vertical, VerticalAlignmentEnum.TOP)  # noqa
Пример #2
0
    def test_only_the_custom_region_is_created(self):
        caption_set = DFXPReader().read(
            SAMPLE_DFXP_TO_RENDER_WITH_ONLY_DEFAULT_POSITIONING_INPUT)

        new_region = Layout(alignment=Alignment(HorizontalAlignmentEnum.LEFT,
                                                VerticalAlignmentEnum.TOP))

        dfxp = SinglePositioningDFXPWriter(new_region).write(caption_set)
        # Using a different parser, because this preserves letter case
        # The output file is ok, but when parsing it, the "regular" parses
        # loses letter case.
        layout = BeautifulSoup(dfxp, features='xml').findChild('layout')

        self.assertEqual(len(layout.findChildren('region')), 1)

        region = layout.findChild('region')
        text_align = region['tts:textAlign']
        display_align = region['tts:displayAlign']

        internal_alignment = _create_internal_alignment(
            text_align, display_align)  # noqa
        self.assertEqual(internal_alignment.horizontal,
                         HorizontalAlignmentEnum.LEFT)  # noqa
        self.assertEqual(internal_alignment.vertical,
                         VerticalAlignmentEnum.TOP)  # noqa
Пример #3
0
    def test_only_the_custom_region_is_created(
            self, sample_dfxp_to_render_with_only_default_positioning_input):
        caption_set = DFXPReader().read(
            sample_dfxp_to_render_with_only_default_positioning_input)

        new_region = Layout(alignment=Alignment(HorizontalAlignmentEnum.LEFT,
                                                VerticalAlignmentEnum.TOP))

        dfxp = SinglePositioningDFXPWriter(new_region).write(caption_set)
        # Using a different parser, because this preserves letter case
        # The output file is ok, but when parsing it, the "regular" parses
        # loses letter case.
        layout = BeautifulSoup(dfxp, features='xml').findChild('layout')

        region = layout.findChild('region')
        text_align = region['tts:textAlign']
        display_align = region['tts:displayAlign']

        internal_alignment = _create_internal_alignment(
            text_align, display_align)

        assert len(layout.findChildren('region')) == 1
        assert internal_alignment.horizontal == HorizontalAlignmentEnum.LEFT
        assert internal_alignment.vertical == VerticalAlignmentEnum.TOP