From e234bd924098c95a5255d8127afc3e8ec284d1ba Mon Sep 17 00:00:00 2001 From: Christian Decker Date: Mon, 21 Sep 2020 18:34:36 +0200 Subject: [PATCH] pytest: Add test for key-value style postgresql DSNs --- tests/test_db.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tests/test_db.py b/tests/test_db.py index 9b39b6844dff..d19dadb8fc9c 100644 --- a/tests/test_db.py +++ b/tests/test_db.py @@ -281,3 +281,20 @@ def test_optimistic_locking(node_factory, bitcoind): l1.rpc.newaddr() assert(l1.daemon.is_in_log(r'Optimistic lock on the database failed')) + + +@unittest.skipIf(os.environ.get('TEST_DB_PROVIDER', None) != 'postgres', "Only applicable to postgres") +def test_psql_key_value_dsn(node_factory, db_provider, monkeypatch): + from pyln.testing.db import PostgresDb + + # Override get_dsn method to use the key-value style DSN + def get_dsn(self): + print("hello") + return "postgres://host=127.0.0.1 port={port} user=postgres password=password dbname={dbname}".format( + port=self.port, dbname=self.dbname + ) + + monkeypatch.setattr(PostgresDb, "get_dsn", get_dsn) + l1 = node_factory.get_node() + opt = [o for o in l1.daemon.cmd_line if '--wallet' in o][0] + assert('host=127.0.0.1' in opt)