--- a/server/migractions.py Thu Feb 26 13:10:33 2009 +0100
+++ b/server/migractions.py Thu Feb 26 13:12:04 2009 +0100
@@ -905,6 +905,13 @@
if commit:
self.commit()
+ def cmd_set_state(self, eid, statename, commit=False):
+ self.session.set_pool() # ensure pool is set
+ entity = self.session.eid_rset(eid).get_entity(0, 0)
+ entity.change_state(entity.wf_state(statename).eid)
+ if commit:
+ self.commit()
+
# EProperty handling ######################################################
def cmd_property_value(self, pkey):
--- a/server/test/unittest_migractions.py Thu Feb 26 13:10:33 2009 +0100
+++ b/server/test/unittest_migractions.py Thu Feb 26 13:12:04 2009 +0100
@@ -40,6 +40,8 @@
self.mh = ServerMigrationHelper(self.repo.config, migrschema,
repo=self.repo, cnx=self.cnx,
interactive=False)
+ assert self.cnx is self.mh._cnx
+ assert self.session is self.mh.session, (self.session.id, self.mh.session.id)
def test_add_attribute_int(self):
self.failIf('whatever' in self.schema)
@@ -424,6 +426,16 @@
# why this commit is necessary is unclear to me (though without it
# next test may fail complaining of missing tables
self.commit()
+
+ def test_set_state(self):
+ user = self.session.user
+ self.set_debug(True)
+ self.mh.set_state(user.eid, 'deactivated')
+ user.clear_related_cache('in_state', 'subject')
+ try:
+ self.assertEquals(user.state, 'deactivated')
+ finally:
+ self.set_debug(False)
if __name__ == '__main__':
unittest_main()