def target_ref_fixture_(self, request, part): rId = 'rId246' url = 'https://github.com/scanny/python-pptx' rels = RelationshipCollection(None) rels.add_relationship(None, url, rId, is_external=True) part._rels = rels return part, rId, url
def it_can_add_a_relationship(self, _Relationship_): baseURI, rId, reltype, target, external = ("baseURI", "rId9", "reltype", "target", False) rels = RelationshipCollection(baseURI) rel = rels.add_relationship(reltype, target, rId, external) _Relationship_.assert_called_once_with(rId, reltype, target, baseURI, external) assert rels[rId] == rel assert rel == _Relationship_.return_value
def it_can_add_a_relationship(self, _Relationship_): baseURI, rId, reltype, target, external = ('baseURI', 'rId9', 'reltype', 'target', False) rels = RelationshipCollection(baseURI) rel = rels.add_relationship(reltype, target, rId, external) _Relationship_.assert_called_once_with(rId, reltype, target, baseURI, external) assert rels[rId] == rel assert rel == _Relationship_.return_value
def it_can_add_a_relationship(self, _Relationship_): baseURI, rId, reltype, target, is_external = ( 'baseURI', 'rId9', 'reltype', 'target', False ) rels = RelationshipCollection(baseURI) rel = rels.add_relationship(reltype, target, rId, is_external) _Relationship_.assert_called_once_with( rId, reltype, target, baseURI, is_external ) assert rels[rId] == rel assert rel == _Relationship_.return_value
def rels(self): """ Populated RelationshipCollection instance that will exercise the rels.xml property. """ rels = RelationshipCollection("/baseURI") rels.add_relationship(reltype="http://rt-hyperlink", target="http://some/link", rId="rId1", is_external=True) part = Mock(name="part") part.partname.relative_ref.return_value = "../media/image1.png" rels.add_relationship(reltype="http://rt-image", target=part, rId="rId2") return rels
def it_can_add_a_relationship(self, _Relationship_): baseURI, rId, reltype, target, is_external = ( "baseURI", "rId9", "reltype", "target", False, ) rels = RelationshipCollection(baseURI) rel = rels.add_relationship(reltype, target, rId, is_external) _Relationship_.assert_called_once_with(rId, reltype, target, baseURI, is_external) assert rels[rId] == rel assert rel == _Relationship_.return_value
def rels(self): """ Populated RelationshipCollection instance that will exercise the rels.xml property. """ rels = RelationshipCollection('/baseURI') rels.add_relationship( reltype='http://rt-hyperlink', target='http://some/link', rId='rId1', is_external=True ) part = Mock(name='part') part.partname.relative_ref.return_value = '../media/image1.png' rels.add_relationship(reltype='http://rt-image', target=part, rId='rId2') return rels
def rels(self): """ Populated RelationshipCollection instance that will exercise the rels.xml property. """ rels = RelationshipCollection("/baseURI") rels.add_relationship( reltype="http://rt-hyperlink", target="http://some/link", rId="rId1", is_external=True, ) part = Mock(name="part") part.partname.relative_ref.return_value = "../media/image1.png" rels.add_relationship(reltype="http://rt-image", target=part, rId="rId2") return rels
def it_should_raise_on_failed_lookup_by_rId(self): rels = RelationshipCollection(None) with pytest.raises(KeyError): rels["barfoo"]
def rels(self, _baseURI): return RelationshipCollection(_baseURI)
def build(self): rels = RelationshipCollection() for rel in self.relationships: rels.add_rel(rel) return rels
def add_matching_ext_rel_fixture_(self, request, reltype, url): rId = 'rId369' rels = RelationshipCollection(None) rels.add_relationship(reltype, url, rId, is_external=True) return rels, reltype, url, rId
def add_matching_ext_rel_fixture_(self, request, reltype, url): rId = "rId369" rels = RelationshipCollection(None) rels.add_relationship(reltype, url, rId, is_external=True) return rels, reltype, url, rId
def add_ext_rel_fixture_(self, reltype, url): rels = RelationshipCollection(None) return rels, reltype, url
def it_has_dict_style_lookup_of_rel_by_rId(self): rel = Mock(name='rel', rId='foobar') rels = RelationshipCollection(None) rels['foobar'] = rel assert rels['foobar'] == rel
def it_has_dict_style_lookup_of_rel_by_rId(self): rel = Mock(name="rel", rId="foobar") rels = RelationshipCollection(None) rels["foobar"] = rel assert rels["foobar"] == rel
def it_has_a_len(self): rels = RelationshipCollection(None) assert len(rels) == 0