當前位置: 首頁>>代碼示例>>Python>>正文


Python postponed_tasks.PostponedTaskPrototype類代碼示例

本文整理匯總了Python中the_tale.common.postponed_tasks.PostponedTaskPrototype的典型用法代碼示例。如果您正苦於以下問題:Python PostponedTaskPrototype類的具體用法?Python PostponedTaskPrototype怎麽用?Python PostponedTaskPrototype使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了PostponedTaskPrototype類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_1_process

    def test_1_process(self):
        self.assertEqual(PostponedTaskPrototype._model_class.objects.all().count(), 0)
        self.assertEqual(ChangeCredentialsTaskPrototype._model_class.objects.all().count(), 0)

        new_password = self.task.process(logger=mock.Mock())
        self.assertTrue(self.task.is_processed)
        self.assertEqual(django_authenticate(nick='test_user', password='111111').id, self.account.id)

        self.assertEqual(PostponedTaskPrototype._model_class.objects.all().count(), 1)
        self.assertEqual(ChangeCredentialsTaskPrototype._model_class.objects.all().count(), 1)

        PostponedTaskPrototype._db_get_object(0).process(logger=mock.Mock())

        self.assertEqual(django_authenticate(nick='test_user', password='111111'), None)
        self.assertEqual(django_authenticate(nick='test_user', password=new_password).id, self.account.id)
開發者ID:Alkalit,項目名稱:the-tale,代碼行數:15,代碼來源:test_reset_password.py

示例2: purchase_lot

def purchase_lot(buyer_id, lot):
    from the_tale.common.postponed_tasks import PostponedTaskPrototype
    from the_tale.finances.market import postponed_tasks

    invoice = bank_prototypes.InvoicePrototype.create(recipient_type=bank_relations.ENTITY_TYPE.GAME_ACCOUNT,
                                                      recipient_id=lot.seller_id,
                                                      sender_type=bank_relations.ENTITY_TYPE.GAME_ACCOUNT,
                                                      sender_id=buyer_id,
                                                      currency=bank_relations.CURRENCY_TYPE.PREMIUM,
                                                      amount=lot.price,
                                                      description_for_sender=u'Покупка «%s»' % lot.name,
                                                      description_for_recipient=u'Продажа «%s»' % lot.name,
                                                      operation_uid=u'market-buy-lot-%s' % lot.type)

    transaction = bank_transaction.Transaction(invoice.id)

    logic_task = postponed_tasks.BuyLotTask(seller_id=lot.seller_id,
                                            buyer_id=buyer_id,
                                            lot_id=lot.id,
                                            transaction=transaction)

    task = PostponedTaskPrototype.create(logic_task)

    amqp_environment.environment.workers.refrigerator.cmd_wait_task(task.id)

    return task
開發者ID:Alkalit,項目名稱:the-tale,代碼行數:26,代碼來源:logic.py

示例3: test_buy

    def test_buy(self):
        self.assertEqual(PostponedTaskPrototype._model_class.objects.all().count(), 0)
        self.assertEqual(InvoicePrototype._model_class.objects.all().count(), 0)

        with mock.patch("the_tale.common.postponed_tasks.PostponedTaskPrototype.cmd_wait") as cmd_wait:
            self.purchase.buy(account=self.account)

        self.assertEqual(cmd_wait.call_count, 1)

        self.assertEqual(PostponedTaskPrototype._model_class.objects.all().count(), 1)
        self.assertEqual(InvoicePrototype._model_class.objects.all().count(), 1)

        postponed_logic = PostponedTaskPrototype._db_get_object(0).internal_logic

        self.assertTrue(isinstance(postponed_logic, BuyPremium))
        self.assertEqual(postponed_logic.account_id, self.account.id)
        self.assertEqual(postponed_logic.days, self.days)

        invoice = InvoicePrototype.get_by_id(postponed_logic.transaction.invoice_id)

        self.assertEqual(invoice.recipient_type, ENTITY_TYPE.GAME_ACCOUNT)
        self.assertEqual(invoice.recipient_id, self.account.id)
        self.assertEqual(invoice.sender_type, ENTITY_TYPE.GAME_LOGIC)
        self.assertEqual(invoice.sender_id, 0)
        self.assertEqual(invoice.currency, CURRENCY_TYPE.PREMIUM)
        self.assertEqual(invoice.amount, -self.cost)
        self.assertEqual(invoice.description_for_sender, u"premium-days-transaction-description")
        self.assertEqual(invoice.description_for_recipient, u"premium-days-transaction-description")
開發者ID:lshestov,項目名稱:the-tale,代碼行數:28,代碼來源:test_goods.py

示例4: test_profile_update_nick

 def test_profile_update_nick(self):
     self.request_login(self.account.email)
     response = self.client.post(reverse('accounts:profile:update'), {'email': self.account.email, 'nick': 'test_nick'})
     self.assertEqual(response.status_code, 200)
     self.check_ajax_processing(response, PostponedTaskPrototype._db_get_object(0).status_url)
     self.assertEqual(ChangeCredentialsTask.objects.all().count(), 1)
     self.assertEqual(ChangeCredentialsTask.objects.all()[0].state, relations.CHANGE_CREDENTIALS_TASK_STATE.CHANGING)
開發者ID:Alkalit,項目名稱:the-tale,代碼行數:7,代碼來源:test_requests_profile.py

示例5: test_success

    def test_success(self):
        self.assertEqual(PostponedTask.objects.all().count(), 0)
        response = self.post_ajax_json(url('game:heroes:reset-abilities', self.hero.id))
        self.assertEqual(PostponedTask.objects.all().count(), 1)

        task = PostponedTaskPrototype._db_get_object(0)

        self.check_ajax_processing(response, task.status_url)
開發者ID:Alkalit,項目名稱:the-tale,代碼行數:8,代碼來源:test_requests.py

示例6: change_credentials

    def change_credentials(self):
        from the_tale.accounts.postponed_tasks import ChangeCredentials

        change_credentials_task = ChangeCredentials(task_id=self.id)
        task = PostponedTaskPrototype.create(change_credentials_task)

        environment.workers.accounts_manager.cmd_task(task.id)

        return task
開發者ID:Alkalit,項目名稱:the-tale,代碼行數:9,代碼來源:prototypes.py

示例7: choose_ability

    def choose_ability(self, ability_id):

        choose_task = postponed_tasks.ChooseHeroAbilityTask(hero_id=self.hero.id, ability_id=ability_id)

        task = PostponedTaskPrototype.create(choose_task)

        environment.workers.supervisor.cmd_logic_task(self.account.id, task.id)

        return self.json_processing(task.status_url)
開發者ID:Alkalit,項目名稱:the-tale,代碼行數:9,代碼來源:views.py

示例8: test_success_multiply_accoutns

    def test_success_multiply_accoutns(self):
        with self.check_delta(PostponedTaskPrototype._db_count, 1):
            self.check_ajax_processing(self.post_ajax_json(url('accounts:messages:create'), {'text': 'test-message', 'recipients': ('%d,%d' % (self.account2.id, self.account3.id))}))

        task = PostponedTaskPrototype._db_latest()

        self.assertEqual(task.internal_logic.message, 'test-message')
        self.assertEqual(task.internal_logic.account_id, self.account1.id)
        self.assertEqual(task.internal_logic.recipients, [self.account2.id, self.account3.id])
開發者ID:Alkalit,項目名稱:the-tale,代碼行數:9,代碼來源:test_requests.py

示例9: test_profile_confirm_email_for_unlogined

    def test_profile_confirm_email_for_unlogined(self):
        self.request_login(self.account.email)
        self.client.post(reverse('accounts:profile:update'), {'email': '[email protected]', 'nick': 'test_nick'})
        self.request_logout()

        uuid = ChangeCredentialsTask.objects.all()[0].uuid

        response = self.client.get(reverse('accounts:profile:confirm-email')+'?uuid='+uuid)
        self.check_response_redirect(response, PostponedTaskPrototype._db_get_object(0).wait_url)
開發者ID:Alkalit,項目名稱:the-tale,代碼行數:9,代碼來源:test_requests_profile.py

示例10: test_choose_processing

    def test_choose_processing(self):
        self.turn_to_quest(self.storage, self.hero.id)

        self.request_login('[email protected]')
        response = self.client.post(url('game:quests:api-choose', option_uid=self.option_uid, api_version='1.0', api_client=project_settings.API_CLIENT))

        task = PostponedTaskPrototype._db_get_object(0)
        self.check_ajax_processing(response, task.status_url)
        self.assertEqual(PostponedTask.objects.all().count(), 1)
開發者ID:Alkalit,項目名稱:the-tale,代碼行數:9,代碼來源:test_requests.py

示例11: test_initialization

    def test_initialization(self):
        from the_tale.common.postponed_tasks import PostponedTask, PostponedTaskPrototype, POSTPONED_TASK_STATE, FakePostponedInternalTask

        PostponedTaskPrototype.create(FakePostponedInternalTask())

        self.assertEqual(PostponedTask.objects.filter(state=POSTPONED_TASK_STATE.WAITING).count(), 1)

        self.worker.process_initialize()

        self.assertEqual(PostponedTask.objects.filter(state=POSTPONED_TASK_STATE.WAITING).count(), 0)
        self.assertEqual(PostponedTask.objects.filter(state=POSTPONED_TASK_STATE.RESETED).count(), 1)

        self.assertEqual(self.worker.tasks, {})
        self.assertEqual(self.worker.accounts_for_tasks, {})
        self.assertEqual(self.worker.accounts_owners, {self.account_1.id: 'game_logic_1', self.account_2.id: 'game_logic_2'})
        self.assertEqual(self.worker.accounts_queues, {})
        self.assertTrue(self.worker.initialized)
        self.assertFalse(self.worker.wait_next_turn_answer)
        self.assertTrue(GameState.is_working())
開發者ID:Alkalit,項目名稱:the-tale,代碼行數:19,代碼來源:test_supervisor_worker.py

示例12: reset_name

    def reset_name(self):
        change_task = postponed_tasks.ChangeHeroTask(hero_id=self.hero.id,
                                     name=names.generator.get_name(self.hero.race, self.hero.gender),
                                     race=self.hero.race,
                                     gender=self.hero.gender)

        task = PostponedTaskPrototype.create(change_task)

        environment.workers.supervisor.cmd_logic_task(self.hero.account_id, task.id)

        return self.json_processing(task.status_url)
開發者ID:Alkalit,項目名稱:the-tale,代碼行數:11,代碼來源:views.py

示例13: reset_abilities

    def reset_abilities(self):

        if not self.hero.abilities.can_reset:
            return self.json_error('heroes.reset_abilities.reset_timeout', u'Сброс способностей пока не доступен')

        reset_task = postponed_tasks.ResetHeroAbilitiesTask(hero_id=self.hero.id)

        task = PostponedTaskPrototype.create(reset_task)

        environment.workers.supervisor.cmd_logic_task(self.account.id, task.id)

        return self.json_processing(task.status_url)
開發者ID:Alkalit,項目名稱:the-tale,代碼行數:12,代碼來源:views.py

示例14: test_change_hero

    def test_change_hero(self):
        self.assertEqual(PostponedTask.objects.all().count(), 0)
        response = self.client.post(url('game:heroes:change-hero', self.hero.id), self.get_post_data())
        self.assertEqual(PostponedTask.objects.all().count(), 1)

        task = PostponedTaskPrototype._db_get_object(0)

        self.check_ajax_processing(response, task.status_url)

        self.assertEqual(task.internal_logic.name, names.generator.get_test_name(name=u'новое имя'))
        self.assertEqual(task.internal_logic.gender, GENDER.MASCULINE)
        self.assertEqual(task.internal_logic.race, RACE.DWARF)
開發者ID:Alkalit,項目名稱:the-tale,代碼行數:12,代碼來源:test_requests.py

示例15: create

def create(context):
    check_recipients(context.form)

    logic_task = postponed_tasks.SendMessagesTask(
        account_id=context.account.id, recipients=context.form.c.recipients, message=context.form.c.text
    )

    task = PostponedTaskPrototype.create(logic_task)

    amqp_environment.environment.workers.accounts_manager.cmd_task(task.id)

    return dext_views.AjaxProcessing(status_url=task.status_url)
開發者ID:lshestov,項目名稱:the-tale,代碼行數:12,代碼來源:views.py


注:本文中的the_tale.common.postponed_tasks.PostponedTaskPrototype類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。