def testChangeJobOwner(self): user1 = User(u"someone", u"somename", u"someemail", "secret") User.add(user1) user2 = User(u"someone2", u"somename2", u"someemail2", "secret2") User.add(user2) job = FakeJob() self.command.job_factory.fromId = MagicMock(name="fromId", return_value=job) JobMeta.add(job.meta) commit() args = Namespace(job=u"37dc6b15-2013-429c-98b7-f058bcf0c274", user=u"someone2") self.command.owner(args) self.assertEqual(DBSession().query(JobMeta.owner).all(), [(u"someone2",)])
def update(self, args): "Update user data" user = User.by_id(args.userid) if 'user' in args: user.userid = args.user for job in user.jobs: job.owner = args.user JobMeta.add(job) if 'name' in args: user.displayname = args.name if 'email' in args: user.email = args.email if 'password' in args: user.password = args.password User.add(user) commit()
def testChangeJobOwner(self): user1 = User(u'someone', u'somename', u'someemail', 'secret') User.add(user1) user2 = User(u'someone2', u'somename2', u'someemail2', 'secret2') User.add(user2) job = FakeJob() self.command.job_factory.fromId = MagicMock(name='fromId', return_value=job) JobMeta.add(job.meta) commit() args = Namespace(job=u'37dc6b15-2013-429c-98b7-f058bcf0c274', user=u'someone2') self.command.owner(args) self.assertEqual(DBSession().query(JobMeta.owner).all(), [(u'someone2', )])
def owner(self, args): """Alter owner of job""" job = self.job_factory.fromId(args.job) job.meta.owner = args.user JobMeta.add(job.meta) commit()