0001-sql-keep-createdb-connection-params-available-after-.patch
tests/test_hobo.py | ||
---|---|---|
19 | 19 |
from wcs.ctl.check_hobos import CmdCheckHobos |
20 | 20 |
from wcs.publisher import WcsPublisher |
21 | 21 |
from wcs import fields |
22 |
from wcs import sql |
|
22 | 23 | |
23 | 24 |
HOBO_JSON = { |
24 | 25 |
'services': [ |
... | ... | |
411 | 412 |
assert call.call_args[0][0][1:] == ['convert-to-sql', |
412 | 413 |
'--dbname', 'tests_wcs_wcs_example_net', |
413 | 414 |
'--user', 'fred', 'wcs.example.net'] |
415 | ||
416 |
pub.reload_cfg() |
|
417 |
assert 'createdb-connection-params' in pub.cfg['postgresql'] |
|
418 |
with mock.patch('psycopg2.connect') as connect: |
|
419 |
sql.get_connection(new=True) |
|
420 |
assert connect.call_args_list[0][1] == {'user': 'fred', 'database': 'tests_wcs_wcs_example_net'} |
wcs/ctl/check_hobos.py | ||
---|---|---|
447 | 447 |
else: |
448 | 448 |
cur.close() |
449 | 449 | |
450 |
postgresql_cfg['database'] = database_name |
|
451 |
pub.cfg['postgresql'] = postgresql_cfg |
|
450 |
pub.cfg['postgresql']['database'] = database_name |
|
452 | 451 |
pub.write_cfg() |
453 | 452 |
pub.set_config(skip_sql=False) |
454 | 453 | |
... | ... | |
460 | 459 |
cmd.extend(['-f', self.base_options.configfile]) |
461 | 460 |
cmd.append('convert-to-sql') |
462 | 461 |
for param in ('database', 'user', 'password', 'host', 'port'): |
463 |
if postgresql_cfg.get(param):
|
|
462 |
if pub.cfg['postgresql'].get(param):
|
|
464 | 463 |
if param == 'database': |
465 | 464 |
cmd.append('--dbname') |
466 | 465 |
else: |
467 | 466 |
cmd.append('--' + param) |
468 |
cmd.append(str(postgresql_cfg.get(param)))
|
|
467 |
cmd.append(str(pub.cfg['postgresql'].get(param)))
|
|
469 | 468 |
cmd.append(str(self.get_instance_path(service))) |
470 | 469 |
subprocess.call(cmd) |
471 | 470 |
wcs/sql.py | ||
---|---|---|
254 | 254 |
if not hasattr(get_publisher(), 'pgconn') or get_publisher().pgconn is None: |
255 | 255 |
postgresql_cfg = {} |
256 | 256 |
for k, v in get_cfg('postgresql', {}).items(): |
257 |
if v:
|
|
257 |
if isinstance(v, basestring):
|
|
258 | 258 |
postgresql_cfg[k] = v |
259 | 259 |
try: |
260 | 260 |
get_publisher().pgconn = psycopg2.connect(**postgresql_cfg) |
261 |
- |