Skip to content

Commit 62b42ce

Browse files
author
Steve Canny
committed
add Part.rels
1 parent 762c02c commit 62b42ce

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

opc/package.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ def __init__(self, partname, content_type, blob):
6464
self._partname = partname
6565
self._content_type = content_type
6666
self._blob = blob
67+
self._rels = RelationshipCollection(partname.baseURI)
6768

6869
@property
6970
def blob(self):
@@ -87,6 +88,13 @@ def partname(self):
8788
"""
8889
return self._partname
8990

91+
@property
92+
def rels(self):
93+
"""
94+
|RelationshipCollection| instance containing rels for this part.
95+
"""
96+
return self._rels
97+
9098
def _add_relationship(self, reltype, target, rId, external=False):
9199
"""
92100
Return newly added |_Relationship| instance of *reltype* between this

tests/test_package.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,8 @@ class DescribePart(object):
7777

7878
@pytest.fixture
7979
def part(self):
80-
return Part(None, None, None)
80+
partname = Mock(name='partname', baseURI='/')
81+
return Part(partname, None, None)
8182

8283
def it_remembers_its_construction_state(self):
8384
partname, content_type, blob = (
@@ -89,6 +90,13 @@ def it_remembers_its_construction_state(self):
8990
assert part.content_type == content_type
9091
assert part.partname == partname
9192

93+
def it_has_a_rels_collection_it_initializes_on_construction(
94+
self, RelationshipCollection_):
95+
partname = Mock(name='partname', baseURI='/')
96+
part = Part(partname, None, None)
97+
RelationshipCollection_.assert_called_once_with('/')
98+
assert part.rels == RelationshipCollection_.return_value
99+
92100
def it_can_add_a_relationship_to_another_part(self, part):
93101
# mockery ----------------------
94102
reltype, target, rId = (

0 commit comments

Comments
 (0)