示例#1
0
 def test_basics(self):
     ent = _MyEntity()
     self._uow.register_new(_MyEntity, ent)
     self.assert_equal(EntityStateManager.get_state(ent),
                       OBJECT_STATES.NEW)
     self.assert_equal([item[1] for item in self._uow.iterator()],
                       [ent])
     self.assert_equal(list(self._uow.get_new(_MyEntity)), [ent])
     self._uow.mark_clean(_MyEntity, ent)
     self.assert_equal(list(self._uow.get_clean(_MyEntity)), [ent])
     self._uow.mark_dirty(_MyEntity, ent)
     self.assert_equal(list(self._uow.get_dirty(_MyEntity)), [ent])
     self._uow.mark_deleted(_MyEntity, ent)
     self.assert_equal(list(self._uow.get_deleted(_MyEntity)), [ent])
     self._uow.unregister(_MyEntity, ent)
     self.assert_equal(list(self._uow.iterator()), [])
     self._uow.reset()
示例#2
0
 def test_get_state_unregistered_fails(self):
     ent = _MyEntity()
     with self.assert_raises(ValueError) as cm:
         EntityStateManager.get_state(ent)
     msg = 'Trying to get the state of an unregistered entity'
     self.assert_true(cm.exception.message.startswith(msg))