Skip to content

Commit 8652073

Browse files
author
Steve Canny
committed
add CT_Relationships.xml
Also added new() method on CT_Relationship to enable integrated test rather than mocking out CT_Relationship.new().
1 parent 9db3241 commit 8652073

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

opc/oxml.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,14 @@ def new():
213213
objectify.deannotate(relationships, cleanup_namespaces=True)
214214
return relationships
215215

216+
@property
217+
def xml(self):
218+
"""
219+
Return XML string for this element, suitable for saving in a .rels
220+
stream, not pretty printed and with an XML declaration at the top.
221+
"""
222+
return oxml_tostring(self, encoding='UTF-8', standalone=True)
223+
216224

217225
class CT_Types(OxmlBaseElement):
218226
"""

tests/test_oxml.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,14 @@ def it_can_build_rels_element_incrementally(self):
9898
pretty_print=True)
9999
assert actual_xml == expected_rels_xml
100100

101+
def it_can_generate_rels_file_xml(self):
102+
expected_xml = (
103+
'<?xml version=\'1.0\' encoding=\'UTF-8\' standalone=\'yes\'?>\n'
104+
'<Relationships xmlns="http://schemas.openxmlformats.org/package'
105+
'/2006/relationships"/>'.encode('utf-8')
106+
)
107+
assert CT_Relationships.new().xml == expected_xml
108+
101109

102110
class DescribeCT_Types(object):
103111

0 commit comments

Comments
 (0)