Example #1
0
 def it_can_construct_from_attribute_values(self):
     cases = (
         ("rId9", "ReLtYpE", "foo/bar.xml", None),
         ("rId9", "ReLtYpE", "bar/foo.xml", RTM.INTERNAL),
         ("rId9", "ReLtYpE", "http://some/link", RTM.EXTERNAL),
     )
     for rId, reltype, target, target_mode in cases:
         if target_mode is None:
             rel = CT_Relationship.new(rId, reltype, target)
         else:
             rel = CT_Relationship.new(rId, reltype, target, target_mode)
         builder = a_Relationship().with_target(target)
         if target_mode == RTM.EXTERNAL:
             builder = builder.with_target_mode(RTM.EXTERNAL)
         expected_rel_xml = builder.xml
         assert rel.xml == expected_rel_xml
Example #2
0
 def it_raises_on_target_partname_when_external(self):
     rel_elm = CT_Relationship.new(
         "rId9", "ReLtYpE", "docProps/core.xml", RTM.EXTERNAL
     )
     srel = _SerializedRelationship("/", rel_elm)
     with pytest.raises(ValueError):
         srel.target_partname
Example #3
0
 def it_can_construct_from_attribute_values(self):
     cases = (
         ("rId9", "ReLtYpE", "foo/bar.xml", None),
         ("rId9", "ReLtYpE", "bar/foo.xml", RTM.INTERNAL),
         ("rId9", "ReLtYpE", "http://some/link", RTM.EXTERNAL),
     )
     for rId, reltype, target, target_mode in cases:
         if target_mode is None:
             rel = CT_Relationship.new(rId, reltype, target)
         else:
             rel = CT_Relationship.new(rId, reltype, target, target_mode)
         builder = a_Relationship().with_target(target)
         if target_mode == RTM.EXTERNAL:
             builder = builder.with_target_mode(RTM.EXTERNAL)
         expected_rel_xml = builder.xml
         assert rel.xml == expected_rel_xml
Example #4
0
 def it_knows_when_it_is_external(self):
     cases = (RTM.INTERNAL, RTM.EXTERNAL)
     expected_values = (False, True)
     for target_mode, expected_value in zip(cases, expected_values):
         rel_elm = CT_Relationship.new('rId9', 'ReLtYpE',
                                       'docProps/core.xml', target_mode)
         srel = _SerializedRelationship(None, rel_elm)
         assert srel.is_external is expected_value
Example #5
0
 def it_knows_when_it_is_external(self):
     cases = (RTM.INTERNAL, RTM.EXTERNAL)
     expected_values = (False, True)
     for target_mode, expected_value in zip(cases, expected_values):
         rel_elm = CT_Relationship.new(
             "rId9", "ReLtYpE", "docProps/core.xml", target_mode
         )
         srel = _SerializedRelationship(None, rel_elm)
         assert srel.is_external is expected_value
Example #6
0
 def it_remembers_construction_values(self):
     # test data --------------------
     rel_elm = CT_Relationship.new('rId9', 'ReLtYpE', 'docProps/core.xml',
                                   RTM.INTERNAL)
     # exercise ---------------------
     srel = _SerializedRelationship('/', rel_elm)
     # verify -----------------------
     assert srel.rId == 'rId9'
     assert srel.reltype == 'ReLtYpE'
     assert srel.target_ref == 'docProps/core.xml'
     assert srel.target_mode == RTM.INTERNAL
 def it_remembers_construction_values(self):
     # test data --------------------
     rel_elm = CT_Relationship.new("rId9", "ReLtYpE", "docProps/core.xml",
                                   RTM.INTERNAL)
     # exercise ---------------------
     srel = _SerializedRelationship("/", rel_elm)
     # verify -----------------------
     assert srel.rId == "rId9"
     assert srel.reltype == "ReLtYpE"
     assert srel.target_ref == "docProps/core.xml"
     assert srel.target_mode == RTM.INTERNAL
Example #8
0
 def it_remembers_construction_values(self):
     # test data --------------------
     rel_elm = CT_Relationship.new(
         "rId9", "ReLtYpE", "docProps/core.xml", RTM.INTERNAL
     )
     # exercise ---------------------
     srel = _SerializedRelationship("/", rel_elm)
     # verify -----------------------
     assert srel.rId == "rId9"
     assert srel.reltype == "ReLtYpE"
     assert srel.target_ref == "docProps/core.xml"
     assert srel.target_mode == RTM.INTERNAL
Example #9
0
 def it_remembers_construction_values(self):
     # test data --------------------
     rel_elm = CT_Relationship.new(
         'rId9', 'ReLtYpE', 'docProps/core.xml', RTM.INTERNAL
     )
     # exercise ---------------------
     srel = _SerializedRelationship('/', rel_elm)
     # verify -----------------------
     assert srel.rId == 'rId9'
     assert srel.reltype == 'ReLtYpE'
     assert srel.target_ref == 'docProps/core.xml'
     assert srel.target_mode == RTM.INTERNAL
Example #10
0
 def it_raises_on_target_partname_when_external(self):
     rel_elm = CT_Relationship.new('rId9', 'ReLtYpE', 'docProps/core.xml',
                                   RTM.EXTERNAL)
     srel = _SerializedRelationship('/', rel_elm)
     with pytest.raises(ValueError):
         srel.target_partname