Example #1
0
 def test_add_money(self):
     """Пополнение баланса"""
     wallet = create_wallet(self.user, self.rub_currency, 0)
     old_balance = wallet.balance
     add_money(self.user, 100)
     wallet = Wallet.objects.get(serial_number=wallet.serial_number)
     self.assertEquals(old_balance + 100, wallet.balance)
Example #2
0
 def test_add_money_incorrect_amount(self):
     """Пополнение баланса с неправильной суммой"""
     wallet = create_wallet(self.user, self.rub_currency, 0)
     with self.assertRaises(ValueError):
         add_money(self.user, -1100)
     with self.assertRaises(ValueError):
         add_money(self.user, 'aaa')
 def setUp(self):
     self.client = Client()
     update_currency_rates()
     self.user_data = {
         'username': '******',
         'email': '*****@*****.**'
     }
     self.user = get_user_model()(**self.user_data)
     self.user.set_password('StrongPassword123')
     self.user.save()
     self.rub_currency = Currency.objects.get(symbol='RUB')
     self.wallet = create_wallet(self.user, self.rub_currency, 0)
Example #4
0
    def setUp(self):

        self.client = Client()
        update_currency_rates()

        self.user_data = {
            'username': '******',
            'email': '*****@*****.**'
        }
        self.user = get_user_model()(**self.user_data)
        self.user.set_password('StrongPassword123')
        self.user.save()
        self.rub_currency = Currency.objects.get(symbol='RUB')
        self.wallet = create_wallet(self.user, self.rub_currency, 1000000)

        self.user_data = {
            'username': '******',
            'email': '*****@*****.**'
        }
        self.user2 = get_user_model()(**self.user_data)
        self.user2.set_password('StrongPassword123')
        self.user2.save()
        self.wallet2 = create_wallet(self.user, self.rub_currency, 1000000)

        self.user_data = {
            'username': '******',
            'email': '*****@*****.**'
        }
        self.user3_usd = get_user_model()(**self.user_data)
        self.user3_usd.set_password('StrongPassword123')
        self.user3_usd.save()
        self.usd_currency = Currency.objects.get(symbol='USD')
        self.wallet3_usd = create_wallet(self.user, self.usd_currency, 1000000)

        self.reason_income = Reason.objects.get(identifier='BASE_INCOME')
        self.reason_expense = Reason.objects.get(identifier='BASE_EXPENSE')
        self.reason_transfer = Reason.objects.get(identifier='BASE_TRANSFER')
Example #5
0
 def test_add_money_incorrect_serial_number(self):
     """Пополнение баланса с неправильным номером счёта"""
     wallet = create_wallet(self.user, self.rub_currency, 0)
     with self.assertRaises(ValueError):
         add_money('111', 100)
Example #6
0
 def test_create_wallet_incorrect_currency(self):
     """Создаём кошелёк с неправильной валютой"""
     with self.assertRaises(IntegrityError):
         wallet = create_wallet(user=self.user, currency=None, balance=0)
     with self.assertRaises(ValueError):
         wallet = create_wallet(user=self.user, currency='AAA', balance=0)
Example #7
0
 def test_create_wallet_no_user(self):
     """Создаём кошелёк без пользователя"""
     with self.assertRaises(IntegrityError):
         wallet = create_wallet(user=None,
                                currency=self.rub_currency,
                                balance=0)
Example #8
0
 def test_create_wallet_incorrect_balance(self):
     """Создаём кошелёк для пользователя c неправильным балансом"""
     with self.assertRaises(ValueError):
         wallet = create_wallet(self.user, self.rub_currency, -1)
     with self.assertRaises(ValueError):
         wallet = create_wallet(self.user, self.rub_currency, 'AAAA')
Example #9
0
 def test_create_wallet(self):
     """Создаём кошелёк для пользователя"""
     wallet = create_wallet(self.user, self.rub_currency, 0)
     cnt = Wallet.objects.filter(id=wallet.id).count()
     self.assertEquals(cnt, 1)
     self.assertIsNotNone(wallet.serial_number)