gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] [taler-bank] branch master updated (632f196 -> e58758d)


From: gnunet
Subject: [GNUnet-SVN] [taler-bank] branch master updated (632f196 -> e58758d)
Date: Wed, 01 Feb 2017 16:33:17 +0100

This is an automated email from the git hooks/post-receive script.

marcello pushed a change to branch master
in repository bank.

    from 632f196  logging
     new 0a1bdb2  adding make check
     new e58758d  Make testcases match refactoring

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 Makefile.am            |   2 +
 talerbank/app/tests.py | 149 ++++++++++++-------------------------------------
 talerbank/app/views.py |   3 +
 3 files changed, 40 insertions(+), 114 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 3ee448a..05534e0 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -22,6 +22,8 @@ pkgdata_DATA = \
 install-dev:
        @pip3 install -e . --install-option="address@hidden@"
 
+check:
+       @export DJANGO_SETTINGS_MODULE="talerbank.settings" 
TALER_PREFIX="@prefix@" && python3 -m django test
 
 # install into prefix
 install-exec-hook:
diff --git a/talerbank/app/tests.py b/talerbank/app/tests.py
index e5bce2c..c1e74b6 100644
--- a/talerbank/app/tests.py
+++ b/talerbank/app/tests.py
@@ -14,145 +14,66 @@
 #
 #  @author Marcello Stanisci
 
-from django.test import TestCase, TransactionTestCase, Client
+from django.test import TestCase, Client
 from django.core.urlresolvers import reverse
+from django.conf import settings
 from django.contrib.auth.models import User
-from .user import register
 from .models import BankAccount
-from django.conf import settings
-from .funds import wire_transfer_in_out
-from .errors import BadWireDetails
-from django.db import connection
-from .management.commands import provide_accounts
-from . import history
-from .amounts import floatify
+
 import logging
-import json
 
 logger = logging.getLogger(__name__)
 
-
-def create_bank_and_user():
-    bank = User.objects.create_user(username='Bank')
-    ba = BankAccount(user=bank, currency=settings.TALER_CURRENCY)
-    ba.save()    
-    user = User.objects.create_user(username='test_login', 
password='test_login')
-    ua = BankAccount(user=user, currency=settings.TALER_CURRENCY)
-    ua.save()
+def clearDb():
+    User.objects.all().delete()
+    BankAccount.objects.all().delete()
 
 
-def reset_db():
-    users = User.objects.all()
-    for u in users:
-        u.delete()
-    cursor = connection.cursor()
-    # Zero the 'account_no' autoincrement counter, because
-    # tables' deletion occurring after each test* function
-    # does NOT reset that counter, and this causes problem when
-    # creating 'Bank' user, since it gets account_no != 1, and
-    # this breaks wiretransfers involving the bank
-    cursor.execute("ALTER SEQUENCE app_bankaccount_account_no_seq RESTART")
-
-class UserTestCase(TestCase):
-    """Test user registration/login/logout"""
+class RegisterTestCase(TestCase):
+    """User registration"""
 
     def setUp(self):
-        create_bank_and_user()
+        bank = User.objects.create_user(username='Bank')
+        ba = BankAccount(user=bank, currency=settings.TALER_CURRENCY)
+        ba.account_no = 1
+        ba.save() 
+        settings.ROOT_URLCONF = "talerbank.app.urls"
 
     def tearDown(self):
-        reset_db()
+        clearDb()
 
     def test_register(self):
         c = Client()
-        response = c.post(reverse('register'),
-                          {'username': 'test_register',
-                           'password': 'test_register'},
+        response = c.post(reverse("register"),
+                          {"username": "test_register",
+                           "password": "test_register"},
                            follow=True)
         self.assertIn(("/profile", 302), response.redirect_chain)
-        # this assertion tests "/profile"'s view
+        # this assertion tests "/profile""s view
         self.assertEqual(200, response.status_code)
-    
 
-    def test_login(self):
-        c = Client()
-        response = c.post(reverse('login'),
-                          {'username': 'test_login',
-                           'password': 'test_login'},
-                          follow=True)
-        self.assertEqual(200, response.status_code)
-        response = c.get(reverse('logout'))
-        self.assertEqual(302, response.status_code)
 
+class LoginTestCase(TestCase):
+    """User login"""
 
-class FundsTestCase(TestCase):
     def setUp(self):
-        logging.disable(logging.CRITICAL)
-        create_bank_and_user()
-
-    def tearDown(self):
-        logging.disable(logging.NOTSET)
-        reset_db()
-
-    def test_wiretransfer(self):
-        wire_transfer_in_out({'value': 100,
-                              'fraction': 0,
-                              'currency': settings.TALER_CURRENCY},
-                             1,
-                             2,
-                             "Joining bonus")
-    def test_addincoming(self):
-        c = Client()
-        data = {'amount': {'value': 1, 'fraction': 0, 'currency': 
settings.TALER_CURRENCY},
-                'debit_account': 1,
-                'credit_account': 2,
-                'wtid': 'TEST'}
-        response = c.post(reverse('add-incoming'), json.dumps(data), 
content_type="application/json")
-        self.assertEqual(200, response.status_code)
+        user = User.objects.create_user(username="test_user",
+                                        password="test_password")
+        user_account = BankAccount(user=user,
+                                   currency=settings.TALER_CURRENCY)
+        user_account.save()
+        settings.ROOT_URLCONF = "talerbank.app.urls"
 
-class HistoryTestCase(TestCase):
-    def setUp(self):
-        logging.disable(logging.CRITICAL)
-        provide_accounts.basic_accounts()
-        provide_accounts.demo_accounts()
 
     def tearDown(self):
-        logging.disable(logging.NOTSET)
-
-    # Extract history from public accounts
-    def test_public_history(self):
-        c = Client() 
-        response = c.get(reverse('public-accounts'), follow=True)
-        self.assertEqual(200, response.status_code)
-        response = c.get(reverse('public-accounts'), {'account': 'GNUnet'})
-        self.assertEqual(200, response.status_code)
-
+        clearDb()
+        pass
+    
 
-class CaptchaTestCase(TestCase):
-    def test_pin_tan_question(self): 
+    def test_login(self):
         c = Client()
-        User.objects.create_user(username='test_pintan', 
password='test_pintan')
-        c.login(username='test_pintan', password='test_pintan')
-        wiredetails = {'test':
-                          {'type': 'test',
-                           'account_number': 0,
-                           'bank_uri': 'http://test',
-                           'name': 'test',
-                           'salt': 'test',
-                           'sig': 'test',
-                           'uri': 'test'}}   
-        data = {'amount_value': 1,
-                'amount_fraction': 0,
-                'amount_currency': settings.TALER_CURRENCY,
-                'exchange': 'http://test',
-                'reserve_pub': 'TEST',
-                'wire_details': json.dumps(wiredetails)}
-        response = c.get(reverse('pin_tan'), data)
-        self.assertEqual(200, response.status_code)
-
-
-class FloatifyTestCase(TestCase):
-    def test_floatify(self):
-        data = {'value': 3, 'fraction': 700, 'currency': 
settings.TALER_CURRENCY}
-        result = 3 + (float(700) / float(1000000))
-        ret = floatify(data)
-        self.assertEqual(result, ret)
+        response = c.post(reverse("login"),
+                          {"username": "test_user",
+                           "password": "test_password"},
+                           follow=True)
+        self.assertIn(("/profile", 302), response.redirect_chain)
diff --git a/talerbank/app/views.py b/talerbank/app/views.py
index 50e3771..fc4abfb 100644
--- a/talerbank/app/views.py
+++ b/talerbank/app/views.py
@@ -75,6 +75,9 @@ def get_session_flag(request, name):
     return False
 
 
+# Check if user's logged in.  Check if he/she has withdrawn or
+# registered; render profile page.
+
 @login_required
 def profile_page(request):
     just_withdrawn = get_session_flag(request, "just_withdrawn")

-- 
To stop receiving notification emails like this one, please contact
address@hidden



reply via email to

[Prev in Thread] Current Thread [Next in Thread]