Exemple #1
0
 def test_account_with_different_currency(self):
     AccountPrototype.create(entity_type=ENTITY_TYPE.GAME_ACCOUNT,
                             entity_id=self.entity_id,
                             currency=CURRENCY_TYPE.NORMAL)
     self.assertEqual(
         AccountPrototype._model_class.objects.filter(
             entity_id=self.entity_id).count(), 2)
Exemple #2
0
    def test_freeze__for_noninfinite_both(self):
        recipient = AccountPrototype.create(
            entity_type=ENTITY_TYPE.GAME_ACCOUNT, entity_id=self.recipient_id, currency=CURRENCY_TYPE.PREMIUM
        )
        recipient.amount = 100
        recipient.save()

        sender = AccountPrototype.create(
            entity_type=ENTITY_TYPE.GAME_ACCOUNT, entity_id=self.sender_id, currency=CURRENCY_TYPE.PREMIUM
        )
        sender.amount = 100
        sender.save()

        self.check_freeze(
            recipient_type=ENTITY_TYPE.GAME_ACCOUNT,
            sender_type=ENTITY_TYPE.GAME_ACCOUNT,
            amount=100,
            initial_accounts_number=2,
            recipient_amount=100,
            sender_amount=100,
        )

        self.check_freeze(
            recipient_type=ENTITY_TYPE.GAME_ACCOUNT,
            sender_type=ENTITY_TYPE.GAME_ACCOUNT,
            amount=-50,
            initial_accounts_number=2,
            recipient_amount=100,
            sender_amount=100,
        )
Exemple #3
0
 def test_account_with_different_entity_type(self):
     AccountPrototype.create(entity_type=ENTITY_TYPE.GAME_LOGIC,
                             entity_id=self.entity_id,
                             currency=CURRENCY_TYPE.PREMIUM)
     self.assertEqual(
         AccountPrototype._model_class.objects.filter(
             entity_id=self.entity_id).count(), 2)
Exemple #4
0
    def test_freeze__for_noninfinite_both(self):
        recipient = AccountPrototype.create(
            entity_type=ENTITY_TYPE.GAME_ACCOUNT,
            entity_id=self.recipient_id,
            currency=CURRENCY_TYPE.PREMIUM)
        recipient.amount = 100
        recipient.save()

        sender = AccountPrototype.create(entity_type=ENTITY_TYPE.GAME_ACCOUNT,
                                         entity_id=self.sender_id,
                                         currency=CURRENCY_TYPE.PREMIUM)
        sender.amount = 100
        sender.save()

        self.check_freeze(recipient_type=ENTITY_TYPE.GAME_ACCOUNT,
                          sender_type=ENTITY_TYPE.GAME_ACCOUNT,
                          amount=100,
                          initial_accounts_number=2,
                          recipient_amount=100,
                          sender_amount=100)

        self.check_freeze(recipient_type=ENTITY_TYPE.GAME_ACCOUNT,
                          sender_type=ENTITY_TYPE.GAME_ACCOUNT,
                          amount=-50,
                          initial_accounts_number=2,
                          recipient_amount=100,
                          sender_amount=100)
Exemple #5
0
    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
Exemple #6
0
    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
Exemple #7
0
 def setUp(self):
     super(AccountPrototypeTests, self).setUp()
     self.entity_id = 2
     self.account = AccountPrototype.create(
         entity_type=ENTITY_TYPE.GAME_ACCOUNT,
         entity_id=self.entity_id,
         currency=CURRENCY_TYPE.PREMIUM)
Exemple #8
0
    def create_bank_account(self, entity_id, amount=0):
        account = AccountPrototype.create(entity_type=ENTITY_TYPE.GAME_ACCOUNT, entity_id=entity_id, currency=CURRENCY_TYPE.PREMIUM)

        account.amount = amount
        account.save()

        return account
Exemple #9
0
    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
Exemple #10
0
    def test_amount__infinit_account(self):
        self.assertTrue(ENTITY_TYPE.GAME_LOGIC.is_infinite)
        account = AccountPrototype.create(entity_type=ENTITY_TYPE.GAME_LOGIC, entity_id=self.entity_id, currency=CURRENCY_TYPE.PREMIUM)
        old_amount = account.amount

        account.amount += 100
        account.amount -= 10

        self.assertEqual(account.amount, old_amount)
Exemple #11
0
    def create_bank_account(self, entity_id, amount=0):
        account = AccountPrototype.create(entity_type=ENTITY_TYPE.GAME_ACCOUNT,
                                          entity_id=entity_id,
                                          currency=CURRENCY_TYPE.PREMIUM)

        account.amount = amount
        account.save()

        return account
Exemple #12
0
    def test_amount__infinit_account(self):
        self.assertTrue(ENTITY_TYPE.GAME_LOGIC.is_infinite)
        account = AccountPrototype.create(entity_type=ENTITY_TYPE.GAME_LOGIC,
                                          entity_id=self.entity_id,
                                          currency=CURRENCY_TYPE.PREMIUM)
        old_amount = account.amount

        account.amount += 100
        account.amount -= 10

        self.assertEqual(account.amount, old_amount)
Exemple #13
0
 def test_account_with_different_entity_type(self):
     AccountPrototype.create(
         entity_type=ENTITY_TYPE.GAME_LOGIC, entity_id=self.entity_id, currency=CURRENCY_TYPE.PREMIUM
     )
     self.assertEqual(AccountPrototype._model_class.objects.filter(entity_id=self.entity_id).count(), 2)
Exemple #14
0
 def test_account_with_different_currency(self):
     AccountPrototype.create(
         entity_type=ENTITY_TYPE.GAME_ACCOUNT, entity_id=self.entity_id, currency=CURRENCY_TYPE.NORMAL
     )
     self.assertEqual(AccountPrototype._model_class.objects.filter(entity_id=self.entity_id).count(), 2)
Exemple #15
0
 def setUp(self):
     super(AccountPrototypeTests, self).setUp()
     self.entity_id = 2
     self.account = AccountPrototype.create(
         entity_type=ENTITY_TYPE.GAME_ACCOUNT, entity_id=self.entity_id, currency=CURRENCY_TYPE.PREMIUM
     )