def test_process_logic_task(self): task = logic.send_good_to_market(seller_id=self.account_1.id, good=self.good_1, price=666) with mock.patch('the_tale.common.postponed_tasks.prototypes.PostponedTaskPrototype.process') as process: with mock.patch('the_tale.common.postponed_tasks.prototypes.PostponedTaskPrototype.do_postsave_actions') as do_postsave_actions: self.worker.process_logic_task(self.account_1.id, task.id) self.assertEqual(process.call_count, 1) self.assertEqual(do_postsave_actions.call_count, 1)
def create(context): if logic.has_lot(context.account.id, context.good.uid): raise dext_utils_exceptions.ViewError( code='lot_exists', message=u'Вы уже выставили этот предмет на продажу') task = logic.send_good_to_market(seller_id=context.account.id, good=context.good, price=context.form.c.price) return dext_views.AjaxProcessing(status_url=task.status_url)
def test_send_good_to_market(self): with mock.patch('the_tale.finances.market.workers.market_manager.Worker.cmd_logic_task') as cmd_logic_task: with self.check_delta(postponed_tasks_models.PostponedTask.objects.count, 1): task = logic.send_good_to_market(seller_id=self.account_1.id, good=self.good_2, price=666) self.assertEqual(task.internal_logic.account_id, self.account_1.id) self.assertEqual(task.internal_logic.good_type, goods_types.test_hero_good.uid) self.assertEqual(task.internal_logic.good_uid, self.good_2.uid) self.assertEqual(task.internal_logic.price, 666) self.assertEqual(cmd_logic_task.call_args_list, [mock.call(self.account_1.id, task.id)])
def test_process_logic_task(self): task = logic.send_good_to_market(seller_id=self.account_1.id, good=self.good_1, price=666) with mock.patch( 'the_tale.common.postponed_tasks.prototypes.PostponedTaskPrototype.process' ) as process: with mock.patch( 'the_tale.common.postponed_tasks.prototypes.PostponedTaskPrototype.do_postsave_actions' ) as do_postsave_actions: self.worker.process_logic_task(self.account_1.id, task.id) self.assertEqual(process.call_count, 1) self.assertEqual(do_postsave_actions.call_count, 1)
def create(context): if logic.has_lot(context.account.id, context.good.uid): raise dext_utils_exceptions.ViewError(code='lot_exists', message='Вы уже выставили этот предмет на продажу') task = logic.send_good_to_market(seller_id=context.account.id, good=context.good, price=context.form.c.price) return dext_views.AjaxProcessing(status_url=task.status_url)