From 848092598215077d52d4141f4ad7a326ea644427 Mon Sep 17 00:00:00 2001 From: Misael Barreto Date: Sun, 30 Jul 2023 18:20:54 -0300 Subject: [PATCH 1/2] =?UTF-8?q?branch:=20misael=5Fconexao=5Fdb=5Ftest=20re?= =?UTF-8?q?spons=C3=A1vel:=20@misaelbarreto=20descri=C3=A7=C3=A3o:=20*=20A?= =?UTF-8?q?juste=20para=20que=20sejam=20utilizados=20somente=20os=20dados?= =?UTF-8?q?=20de=20conex=C3=A3o=20de=20banco=20definidos=20pelo=20usu?= =?UTF-8?q?=C3=A1rio=20durante=20a=20execu=C3=A7=C3=A3o=20dos=20testes.=20?= =?UTF-8?q?Ex:=20Caso=20ele=20n=C3=A3o=20tenha=20passado=20o=20par=C3=A2me?= =?UTF-8?q?tro=20"host",=20n=C3=A3o=20usaremos=20esse=20par=C3=A2metro,=20?= =?UTF-8?q?permitindo=20assim=20conex=C3=A3o=20local=20via=20socket;?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sloth/test/selenium/__init__.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/sloth/test/selenium/__init__.py b/sloth/test/selenium/__init__.py index b39d7dc..3376fc1 100644 --- a/sloth/test/selenium/__init__.py +++ b/sloth/test/selenium/__init__.py @@ -249,11 +249,19 @@ def tearDownClass(cls): cls.browser.service.stop() def postgres_parameters(self): - dbhost = settings.DATABASES['default']['HOST'] dbuser = settings.DATABASES['default']['USER'] dbport = settings.DATABASES['default']['PORT'] - dbparam = '-U {} -h {} -p {}'.format(dbuser, dbhost, dbport) - return dbparam + dbhost = settings.DATABASES['default']['HOST'] + + dbparams = '' + if (dbuser): + dbparams += f' -U {dbuser}' + if (dbhost): + dbparams += f' -h {dbhost}' + if (dbport): + dbparams += f' -p {dbport}' + + return dbparams def create_dev_database(self, fname=None): dbname = settings.DATABASES['default']['NAME'] From 009e918863d3f82a1cb2c9b2d2243a18d71e7fbc Mon Sep 17 00:00:00 2001 From: Misael Barreto Date: Sun, 30 Jul 2023 18:29:45 -0300 Subject: [PATCH 2/2] =?UTF-8?q?branch:=20misael=5Fconexao=5Fdb=5Ftest=20re?= =?UTF-8?q?spons=C3=A1vel:=20@misaelbarreto=20descri=C3=A7=C3=A3o:=20*=20P?= =?UTF-8?q?equeno=20ajuste=20para=20usar=20a=20fun=C3=A7=C3=A3o=20format.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sloth/test/selenium/__init__.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sloth/test/selenium/__init__.py b/sloth/test/selenium/__init__.py index 3376fc1..5234498 100644 --- a/sloth/test/selenium/__init__.py +++ b/sloth/test/selenium/__init__.py @@ -255,11 +255,11 @@ def postgres_parameters(self): dbparams = '' if (dbuser): - dbparams += f' -U {dbuser}' + dbparams += ' -U {}'.format(dbuser) if (dbhost): - dbparams += f' -h {dbhost}' + dbparams += ' -h {}'.format(dbhost) if (dbport): - dbparams += f' -p {dbport}' + dbparams += ' -p {}'.format(dbport) return dbparams