# HG changeset patch # User sylvain.thenault@logilab.fr # Date 1235650324 -3600 # Node ID 1efba3fd136425f9f2254c94777f97049d8edd10 # Parent 3abae727d121aa4f88048115af8e7fd901c1e7fb set_state command in shell diff -r 3abae727d121 -r 1efba3fd1364 server/migractions.py --- 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): diff -r 3abae727d121 -r 1efba3fd1364 server/test/unittest_migractions.py --- 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()