def test_task_crud(self): # make a fake task for posting a simple message nick = '*****@*****.**' action = 'post' uuid = 'forever' message = 'more' actor_ref = api.actor_get(api.ROOT, nick) # STOP TIME! OMG! test_util.utcnow = lambda: self.now # makin l = profile.label('api_task_create') task_ref = api.task_create(actor_ref, nick, action, uuid, args=[], kw={'nick': nick, 'message': message, 'uuid': uuid } ) l.stop() # grabbin l = profile.label('api_task_get (unlocked)') task_ref = api.task_get(actor_ref, nick, action, uuid) l.stop() # grab again, LOCK VILLE def _again(): task_ref = api.task_get(actor_ref, nick, action, uuid) l = profile.label('api_task_get (locked)') self.assertRaises(exception.ApiLocked, _again) l.stop() # increment time new_now = self.now + self.delta test_util.utcnow = lambda: new_now # grab again, EXPIRED task_ref = api.task_get(actor_ref, nick, action, uuid) # locked if we try again self.assertRaises(exception.ApiLocked, _again) # updatin l = profile.label('api_task_update') task_ref = api.task_update(actor_ref, nick, action, uuid, '1') l.stop() self.assertEqual(task_ref.progress, '1') # grab again, FRESH AND CLEAN task_ref = api.task_get(actor_ref, nick, action, uuid) self.assertEqual(task_ref.progress, '1') # removin l = profile.label('api_task_remove') api.task_remove(actor_ref, nick, action, uuid) l.stop() # grab again, NOT FOUND def _not_found(): task_ref = api.task_get(actor_ref, nick, action, uuid) self.assertRaises(exception.ApiNotFound, _not_found)
def _again(): task_ref = api.task_get(actor_ref, nick, action, uuid)
def _not_found(): task_ref = api.task_get(actor_ref, nick, action, uuid)