def setUp(self): super(_BaseBuyPosponedTaskTests, self).setUp() create_test_map() self.initial_amount = 500 self.amount = 130 result, account_id, bundle_id = register_user('test_user', '*****@*****.**', '111111') self.account = AccountPrototype.get_by_id(account_id) self.bank_account = BankAccountPrototype.create(entity_type=ENTITY_TYPE.GAME_ACCOUNT, entity_id=self.account.id, currency=CURRENCY_TYPE.PREMIUM) self.bank_account.amount = self.initial_amount self.bank_account.save() self.invoice = InvoicePrototype.create(recipient_type=ENTITY_TYPE.GAME_ACCOUNT, recipient_id=self.account.id, sender_type=ENTITY_TYPE.GAME_LOGIC, sender_id=0, currency=CURRENCY_TYPE.PREMIUM, amount=-self.amount, description_for_sender='transaction-description-for-sender', description_for_recipient='transaction-description-for-recipient', operation_uid='transaction-operation-ui') self.transaction = Transaction(self.invoice.id) self.task = None self.storage = None self.cmd_update_with_account_data__call_count = 1 self.accounts_manages_worker = True self.supervisor_worker = False
def setUp(self): super(_BaseBuyPosponedTaskTests, self).setUp() create_test_map() self.initial_amount = 500 self.amount = 130 self.account = self.accounts_factory.create_account() self.bank_account = BankAccountPrototype.create( entity_type=ENTITY_TYPE.GAME_ACCOUNT, entity_id=self.account.id, currency=CURRENCY_TYPE.PREMIUM ) self.bank_account.amount = self.initial_amount self.bank_account.save() self.invoice = InvoicePrototype.create( recipient_type=ENTITY_TYPE.GAME_ACCOUNT, recipient_id=self.account.id, sender_type=ENTITY_TYPE.GAME_LOGIC, sender_id=0, currency=CURRENCY_TYPE.PREMIUM, amount=-self.amount, description_for_sender="transaction-description-for-sender", description_for_recipient="transaction-description-for-recipient", operation_uid="transaction-operation-ui", ) self.transaction = Transaction(self.invoice.id) self.task = None self.storage = None self.cmd_update_with_account_data__call_count = 1 self.accounts_manages_worker = True self.supervisor_worker = False
def create(cls, recipient_type, recipient_id, sender_type, sender_id, currency, amount, description_for_sender, description_for_recipient, operation_uid, force=False): invoice = InvoicePrototype.create( recipient_type=recipient_type, recipient_id=recipient_id, sender_type=sender_type, sender_id=sender_id, currency=currency, amount=amount, description_for_sender=description_for_sender, description_for_recipient=description_for_recipient, operation_uid=operation_uid, force=force) environment.workers.bank_processor.cmd_init_invoice() return cls(invoice_id=invoice.id)
def create_invoice( self, recipient_type=ENTITY_TYPE.GAME_ACCOUNT, recipient_id=3, sender_type=ENTITY_TYPE.GAME_LOGIC, sender_id=8, currency=CURRENCY_TYPE.PREMIUM, amount=317, state=None, description_for_sender='invoice-description-for-sender', description_for_recipient='invoice-description-for-recipient', operation_uid='test-uid', force=False): invoice = InvoicePrototype.create( recipient_type=recipient_type, recipient_id=recipient_id, sender_type=sender_type, sender_id=sender_id, currency=currency, amount=amount, description_for_sender=description_for_sender, description_for_recipient=description_for_recipient, operation_uid=operation_uid, force=force) if state is not None: invoice.state = state invoice.save() return invoice
def create_invoice(self, recipient_type=ENTITY_TYPE.GAME_ACCOUNT, recipient_id=3, sender_type=ENTITY_TYPE.GAME_LOGIC, sender_id=8, currency=CURRENCY_TYPE.PREMIUM, amount=317, state=None, description_for_sender='invoice-description-for-sender', description_for_recipient='invoice-description-for-recipient', operation_uid='test-uid', force=False): invoice = InvoicePrototype.create(recipient_type=recipient_type, recipient_id=recipient_id, sender_type=sender_type, sender_id=sender_id, currency=currency, amount=amount, description_for_sender=description_for_sender, description_for_recipient=description_for_recipient, operation_uid=operation_uid, force=force) if state is not None: invoice.state = state invoice.save() return invoice
def setUp(self): super(_BaseBuyPosponedTaskTests, self).setUp() create_test_map() self.initial_amount = 500 self.amount = 130 self.account = self.accounts_factory.create_account() self.bank_account = BankAccountPrototype.create( entity_type=ENTITY_TYPE.GAME_ACCOUNT, entity_id=self.account.id, currency=CURRENCY_TYPE.PREMIUM) self.bank_account.amount = self.initial_amount self.bank_account.save() self.invoice = InvoicePrototype.create( recipient_type=ENTITY_TYPE.GAME_ACCOUNT, recipient_id=self.account.id, sender_type=ENTITY_TYPE.GAME_LOGIC, sender_id=0, currency=CURRENCY_TYPE.PREMIUM, amount=-self.amount, description_for_sender='transaction-description-for-sender', description_for_recipient='transaction-description-for-recipient', operation_uid='transaction-operation-ui') self.transaction = Transaction(self.invoice.id) self.task = None self.storage = None self.cmd_update_with_account_data__call_count = 1 self.accounts_manages_worker = True self.supervisor_worker = False
def _create_outcoming_invoice(self, amount, state=INVOICE_STATE.FROZEN): invoice = InvoicePrototype.create(sender_type=self.account.entity_type, sender_id=self.account.entity_id, recipient_type=ENTITY_TYPE.GAME_LOGIC, recipient_id=0, currency=CURRENCY_TYPE.PREMIUM, amount=amount, description_for_sender='outcoming invoice for sender', description_for_recipient='outcoming invoice for recipient', operation_uid='outcoming-operation-uid') invoice.state = state invoice.save()
def _create_incoming_invoice(self, amount, state=INVOICE_STATE.FROZEN): invoice = InvoicePrototype.create( recipient_type=self.account.entity_type, recipient_id=self.account.entity_id, sender_type=ENTITY_TYPE.GAME_LOGIC, sender_id=0, currency=CURRENCY_TYPE.PREMIUM, amount=amount, description_for_sender='incoming invoice for sender', description_for_recipient='incoming invoice for recipient', operation_uid='incoming-operation-uid') invoice.state = state invoice.save()
def create(cls, recipient_type, recipient_id, sender_type, sender_id, currency, amount, description_for_sender, description_for_recipient, operation_uid, force=False): invoice = InvoicePrototype.create(recipient_type=recipient_type, recipient_id=recipient_id, sender_type=sender_type, sender_id=sender_id, currency=currency, amount=amount, description_for_sender=description_for_sender, description_for_recipient=description_for_recipient, operation_uid=operation_uid, force=force) environment.workers.bank_processor.cmd_init_invoice() return cls(invoice_id=invoice.id)