diff options
Diffstat (limited to 'talerbank/app/tests.py')
-rw-r--r-- | talerbank/app/tests.py | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/talerbank/app/tests.py b/talerbank/app/tests.py index fb2d437..442888a 100644 --- a/talerbank/app/tests.py +++ b/talerbank/app/tests.py @@ -26,7 +26,7 @@ from mock import patch, MagicMock from urllib.parse import unquote from .models import BankAccount, BankTransaction from . import urls -from .views import wire_transfer +from .views import wire_transfer, LoginFailed from .amount import Amount, CurrencyMismatch, BadFormatAmount LOGGER = logging.getLogger() @@ -39,6 +39,7 @@ def clear_db(): with connection.cursor() as cursor: cursor.execute("ALTER SEQUENCE app_bankaccount_account_no_seq RESTART") cursor.execute("ALTER SEQUENCE app_banktransaction_id_seq RESTART") + class WithdrawTestCase(TestCase): def setUp(self): self.user_bank_account = BankAccount( @@ -106,9 +107,7 @@ class WithdrawTestCase(TestCase): args[0].dump() == amount.dump() \ and self.user_bank_account in args \ and "UVZ789" in args \ - and self.exchange_bank_account in args \ - and kwargs.get("session_expand") == \ - {"debt_limit": True}) + and self.exchange_bank_account in args) def tearDown(self): clear_db() @@ -193,16 +192,28 @@ class LoginTestCase(TestCase): user=User.objects.create_user( username="test_user", password="test_password")).save() + self.client = Client() def tearDown(self): clear_db() def test_login(self): - client = Client() - self.assertTrue(client.login(username="test_user", - password="test_password")) - self.assertFalse(client.login(username="test_user", - password="test_passwordii")) + self.assertTrue(self.client.login( + username="test_user", + password="test_password")) + self.assertFalse(self.client.login( + username="test_user", + password="test_passwordii")) + + def test_failing_login(self): + response = self.client.get( + reverse("history", urlconf=urls), {"auth": "basic"}, + **{"HTTP_X_TALER_BANK_USERNAME": "Wrong", + "HTTP_X_TALER_BANK_PASSWORD": "Credentials"}) + data = response.content.decode("utf-8") + self.assertJSONEqual('{"error": "Wrong username/password", "ec": 5212}', json.loads(data)) + self.assertEqual(401, response.status_code) + class AmountTestCase(TestCase): |