File tree 2 files changed +18
-0
lines changed
2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -87,6 +87,19 @@ def extension(self):
87
87
"""
88
88
return self .get ('Extension' )
89
89
90
+ @staticmethod
91
+ def new (ext , content_type ):
92
+ """
93
+ Return a new ``<Default>`` element with attributes set to parameter
94
+ values.
95
+ """
96
+ xml = '<Default xmlns="%s"/>' % nsmap ['ct' ]
97
+ default = oxml_fromstring (xml )
98
+ default .set ('Extension' , ext [1 :])
99
+ default .set ('ContentType' , content_type )
100
+ objectify .deannotate (default , cleanup_namespaces = True )
101
+ return default
102
+
90
103
91
104
class CT_Override (OxmlBaseElement ):
92
105
"""
Original file line number Diff line number Diff line change @@ -22,6 +22,11 @@ def it_provides_read_access_to_xml_values(self):
22
22
assert default .extension == 'xml'
23
23
assert default .content_type == 'application/xml'
24
24
25
+ def it_can_construct_a_new_default_element (self ):
26
+ default = CT_Default .new ('.xml' , 'application/xml' )
27
+ expected_xml = a_Default ().xml
28
+ assert default .xml == expected_xml
29
+
25
30
26
31
class DescribeCT_Override (object ):
27
32
You can’t perform that action at this time.
0 commit comments