コード例 #1
0
    def iter_fixture(self, request, package_):

        def rel(is_external, reltype, part):
            return instance_mock(
                request, _Relationship, is_external=is_external,
                reltype=reltype, target_part=part
            )

        part_mocks = (
            instance_mock(request, Part, name='linked-media'),
            instance_mock(request, Part, name='slide'),
            instance_mock(request, Part, name='embeded-media'),
        )

        rels = (
            rel(True,  RT.MEDIA, part_mocks[0]),
            rel(True,  RT.VIDEO, part_mocks[0]),
            rel(False, RT.SLIDE, part_mocks[1]),
            rel(False, RT.MEDIA, part_mocks[2]),
            rel(False, RT.VIDEO, part_mocks[2]),
        )

        package_.iter_rels.return_value = iter(rels)

        media_parts = _MediaParts(package_)
        expected_parts = [part_mocks[2]]
        return media_parts, expected_parts
コード例 #2
0
ファイル: test_package.py プロジェクト: scanny/python-pptx
    def iter_fixture(self, request, package_):
        def rel(is_external, reltype, part):
            return instance_mock(
                request,
                _Relationship,
                is_external=is_external,
                reltype=reltype,
                target_part=part,
            )

        part_mocks = (
            instance_mock(request, Part, name="linked-media"),
            instance_mock(request, Part, name="slide"),
            instance_mock(request, Part, name="embeded-media"),
        )

        rels = (
            rel(True, RT.MEDIA, part_mocks[0]),
            rel(True, RT.VIDEO, part_mocks[0]),
            rel(False, RT.SLIDE, part_mocks[1]),
            rel(False, RT.MEDIA, part_mocks[2]),
            rel(False, RT.VIDEO, part_mocks[2]),
        )

        package_.iter_rels.return_value = iter(rels)

        media_parts = _MediaParts(package_)
        expected_parts = [part_mocks[2]]
        return media_parts, expected_parts
コード例 #3
0
 def get_or_add_fixture(self, request, package_, media_, MediaPart_,
                        media_part_, _find_by_sha1_):
     media_present = request.param
     media_parts = _MediaParts(package_)
     media_.sha1 = sha1 = '2468'
     calls = [] if media_present else [call(package_, media_)]
     _find_by_sha1_.return_value = media_part_ if media_present else None
     MediaPart_.new.return_value = None if media_present else media_part_
     return media_parts, media_, sha1, MediaPart_, calls, media_part_
コード例 #4
0
ファイル: test_package.py プロジェクト: scanny/python-pptx
 def get_or_add_fixture(
     self, request, package_, media_, MediaPart_, media_part_, _find_by_sha1_
 ):
     media_present = request.param
     media_parts = _MediaParts(package_)
     media_.sha1 = sha1 = "2468"
     calls = [] if media_present else [call(package_, media_)]
     _find_by_sha1_.return_value = media_part_ if media_present else None
     MediaPart_.new.return_value = None if media_present else media_part_
     return media_parts, media_, sha1, MediaPart_, calls, media_part_
コード例 #5
0
 def find_fixture(self, request, _iter_, media_part_):
     media_part_is_present = request.param
     media_parts = _MediaParts(None)
     _iter_.return_value = iter((media_part_,))
     sha1 = 'foobar'
     if media_part_is_present:
         media_part_.sha1 = 'foobar'
         expected_value = media_part_
     else:
         media_part_.sha1 = 'barfoo'
         expected_value = None
     return media_parts, sha1, expected_value
コード例 #6
0
ファイル: test_package.py プロジェクト: scanny/python-pptx
 def find_fixture(self, request, _iter_, media_part_):
     media_part_is_present = request.param
     media_parts = _MediaParts(None)
     _iter_.return_value = iter((media_part_,))
     sha1 = "foobar"
     if media_part_is_present:
         media_part_.sha1 = "foobar"
         expected_value = media_part_
     else:
         media_part_.sha1 = "barfoo"
         expected_value = None
     return media_parts, sha1, expected_value