def test__next_rId_fills_gap(self):
     """_RelationshipCollection._next_rId fills gap in rId sequence"""
     # setup ------------------------
     part1 = _BasePart()
     part2 = _BasePart()
     part3 = _BasePart()
     part4 = _BasePart()
     rel1 = _Relationship('rId1', None, part1)
     rel2 = _Relationship('rId2', None, part2)
     rel3 = _Relationship('rId3', None, part3)
     rel4 = _Relationship('rId4', None, part4)
     cases = (('rId1', (rel2, rel3, rel4)),
              ('rId2', (rel1, rel3, rel4)),
              ('rId3', (rel1, rel2, rel4)),
              ('rId4', (rel1, rel2, rel3)))
     # exercise ---------------------
     expected_rIds = []
     actual_rIds = []
     for expected_rId, rels in cases:
         expected_rIds.append(expected_rId)
         relationships = _RelationshipCollection()
         for rel in rels:
             relationships._additem(rel)
         actual_rIds.append(relationships._next_rId)
     # verify -----------------------
     expected = expected_rIds
     actual = actual_rIds
     msg = "expected rIds %s, got %s" % (expected, actual)
     self.assertEqual(expected, actual, msg)
 def test__additem_raises_on_dup_rId(self):
     """_RelationshipCollection._additem raises on duplicate rId"""
     # setup ------------------------
     part1 = _BasePart()
     part2 = _BasePart()
     rel1 = _Relationship('rId9', None, part1)
     rel2 = _Relationship('rId9', None, part2)
     self.relationships._additem(rel1)
     # verify -----------------------
     with self.assertRaises(ValueError):
         self.relationships._additem(rel2)
 def test__additem_maintains_rId_ordering(self):
     """_RelationshipCollection maintains rId ordering on additem()"""
     # setup ------------------------
     part1 = _BasePart()
     part2 = _BasePart()
     part3 = _BasePart()
     rel1 = _Relationship('rId1', None, part1)
     rel2 = _Relationship('rId2', None, part2)
     rel3 = _Relationship('rId3', None, part3)
     # exercise ---------------------
     self.relationships._additem(rel2)
     self.relationships._additem(rel1)
     self.relationships._additem(rel3)
     # verify -----------------------
     expected = ['rId1', 'rId2', 'rId3']
     actual = [rel._rId for rel in self.relationships]
     msg = "expected ordering %s, got %s" % (expected, actual)
     self.assertEqual(expected, actual, msg)
 def build(self):
     p = _BasePart()
     p.partname = self.partname
     return p
 def setUp(self):
     self.basepart = _BasePart()
     self.cls = _BasePart