[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [taler-bank] branch master updated: also accepting database
From: |
gnunet |
Subject: |
[GNUnet-SVN] [taler-bank] branch master updated: also accepting database connection strings of the form postgres:///dbname?host=/path/to/sockets/dir/. |
Date: |
Tue, 26 Dec 2017 17:19:11 +0100 |
This is an automated email from the git hooks/post-receive script.
marcello pushed a commit to branch master
in repository bank.
The following commit(s) were added to refs/heads/master by this push:
new a7f0006 also accepting database connection strings of the form
postgres:///dbname?host=/path/to/sockets/dir/.
a7f0006 is described below
commit a7f000619d8efbec35f0de0fd8bbb4359f3eb1d5
Author: Marcello Stanisci <address@hidden>
AuthorDate: Tue Dec 26 17:17:03 2017 +0100
also accepting database connection strings of the form
postgres:///dbname?host=/path/to/sockets/dir/.
---
Makefile.am | 6 +++---
bank-check-alt-baddb.conf | 17 -----------------
bank-check-alt-dbnotfound.conf | 17 -----------------
talerbank/app/tests_alt.py | 4 ++--
talerbank/settings.py | 9 +++++----
5 files changed, 10 insertions(+), 43 deletions(-)
diff --git a/Makefile.am b/Makefile.am
index 7085a44..e844785 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -57,7 +57,7 @@ check:
"Testing against bad db string"
@export DJANGO_SETTINGS_MODULE="talerbank.settings" \
TALER_PREFIX="@prefix@" \
- TALER_CONFIG_FILE="bank-check-alt-baddb.conf" \
+ export TALER_BANK_ALTDB="bad db string" \
&& python3 \
-m django test \
--no-input \
@@ -71,7 +71,7 @@ check:
&& python3 \
-m django test \
--no-input \
- talerbank.app.tests_alt.BadMaxDebtOptionTestCase
+ talerbank.app.tests_alt.BadMaxDebitOptionTestCase
@printf ${FMT} ${SEPARATOR} \
"Testing against no currency in config"
@export TALER_BASE_CONFIG="/tmp" \
@@ -87,7 +87,7 @@ check:
"Testing against db not found"
@export DJANGO_SETTINGS_MODULE="talerbank.settings" \
TALER_PREFIX="@prefix@" \
- TALER_CONFIG_FILE="bank-check-alt-dbnotfound.conf" \
+ TALER_BANK_ALTDB="postgres:///idontexist" \
&& python3 ./taler-bank-manage serve-uwsgi ; \
test 4 = $$?
diff --git a/bank-check-alt-baddb.conf b/bank-check-alt-baddb.conf
deleted file mode 100644
index 6861623..0000000
--- a/bank-check-alt-baddb.conf
+++ /dev/null
@@ -1,17 +0,0 @@
-# Config file containing intentional errors, used
-# to test how the bank reacts.
-
-[taler]
-
-CURRENCY = KUDOS
-
-[bank]
-
-# Which database should we use?
-DATABASE = bad db string
-
-# FIXME
-MAX_DEBT = KUDOS:50
-
-# FIXME
-MAX_DEBT_BANK = KUDOS:0
diff --git a/bank-check-alt-dbnotfound.conf b/bank-check-alt-dbnotfound.conf
deleted file mode 100644
index 6c47d07..0000000
--- a/bank-check-alt-dbnotfound.conf
+++ /dev/null
@@ -1,17 +0,0 @@
-# Config file containing intentional errors, used
-# to test how the bank reacts.
-
-[taler]
-
-CURRENCY = KUDOS
-
-[bank]
-
-# Which database should we use?
-DATABASE = postgres:///idontexist
-
-# FIXME
-MAX_DEBT = KUDOS:50
-
-# FIXME
-MAX_DEBT_BANK = KUDOS:0
diff --git a/talerbank/app/tests_alt.py b/talerbank/app/tests_alt.py
index 423ebb4..9f54aa1 100644
--- a/talerbank/app/tests_alt.py
+++ b/talerbank/app/tests_alt.py
@@ -22,8 +22,8 @@ from .amount import Amount, BadFormatAmount
LOGGER = logging.getLogger()
LOGGER.setLevel(logging.WARNING)
-class BadMaxDebtOptionTestCase(TestCase):
- def test_badmaxdebtoption(self):
+class BadMaxDebitOptionTestCase(TestCase):
+ def test_badmaxdebitoption(self):
with self.assertRaises(BadFormatAmount):
Amount.parse(settings.TALER_MAX_DEBT)
Amount.parse(settings.TALER_MAX_DEBT_BANK)
diff --git a/talerbank/settings.py b/talerbank/settings.py
index 07b8124..28ccaeb 100644
--- a/talerbank/settings.py
+++ b/talerbank/settings.py
@@ -104,13 +104,14 @@ if not DBNAME:
LOGGER.info("dbname: %s" % DBNAME)
-CHECK_DBSTRING_FORMAT = re.search("[a-z]+:///[a-z]+", DBNAME)
+CHECK_DBSTRING_FORMAT = re.search("[a-z]+:///[a-z]+([\?][a-z]+=[a-z/]+)?",
DBNAME)
if not CHECK_DBSTRING_FORMAT:
- LOGGER.error("Bad db string given, respect the format" \
- "'dbtype:///dbname'")
+ LOGGER.error("Bad db string given '%s', respect the format" \
+ "'dbtype:///dbname'" % DBNAME)
sys.exit(2)
DBCONFIG = {}
+# Maybe trust the parsing from urlparse?
DB_URL = urllib.parse.urlparse(DBNAME)
if DB_URL.scheme not in ("postgres") or DB_URL.scheme == "":
@@ -130,7 +131,7 @@ else:
HOST = DB_URL.netloc
if HOST:
- DBCONFIG["HOST"] = HOST
+ DBCONFIG["HOST"] = HOST # Sockets directory.
DATABASES["default"] = DBCONFIG
--
To stop receiving notification emails like this one, please contact
address@hidden
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] [taler-bank] branch master updated: also accepting database connection strings of the form postgres:///dbname?host=/path/to/sockets/dir/.,
gnunet <=