0001-sql-use-dbname-parameter-for-connecting-to-database-.patch
tests/test_ctl.py | ||
---|---|---|
291 | 291 |
} |
292 | 292 |
delete_cmd.delete_tenant(pub, sub_options, []) |
293 | 293 | |
294 |
pgconn = psycopg2.connect(**pub.cfg['postgresql']['createdb-connection-params']) |
|
294 |
connect_kwargs = {'dbname': 'postgres', 'user': pub.cfg['postgresql']['user']} |
|
295 |
pgconn = psycopg2.connect(**connect_kwargs) |
|
295 | 296 |
cur = pgconn.cursor() |
296 | 297 | |
297 | 298 |
cur.execute( |
... | ... | |
315 | 316 |
} |
316 | 317 |
delete_cmd.delete_tenant(pub, sub_options, []) |
317 | 318 | |
318 |
pgconn = psycopg2.connect(**pub.cfg['postgresql']['createdb-connection-params'])
|
|
319 |
pgconn = psycopg2.connect(**connect_kwargs)
|
|
319 | 320 |
pgconn.set_isolation_level(psycopg2.extensions.ISOLATION_LEVEL_AUTOCOMMIT) |
320 | 321 |
cur = pgconn.cursor() |
321 | 322 |
tests/test_hobo.py | ||
---|---|---|
446 | 446 |
pub.initialize_sql = mock.Mock() |
447 | 447 |
with mock.patch('psycopg2.connect') as connect: |
448 | 448 |
hobo_cmd.configure_sql(service, pub) |
449 |
assert connect.call_args_list[0][1] == {'user': 'test', 'database': 'postgres'}
|
|
450 |
assert connect.call_args_list[1][1] == {'user': 'fred', 'database': 'tests_wcs_wcs_example_net'}
|
|
449 |
assert connect.call_args_list[0][1] == {'user': 'test', 'dbname': 'postgres'}
|
|
450 |
assert connect.call_args_list[1][1] == {'user': 'fred', 'dbname': 'tests_wcs_wcs_example_net'}
|
|
451 | 451 |
assert pub.initialize_sql.call_count == 1 |
452 | 452 | |
453 | 453 |
pub.reload_cfg() |
454 | 454 |
assert 'createdb-connection-params' in pub.cfg['postgresql'] |
455 | 455 |
with mock.patch('psycopg2.connect') as connect: |
456 | 456 |
sql.get_connection(new=True) |
457 |
assert connect.call_args_list[0][1] == {'user': 'fred', 'database': 'tests_wcs_wcs_example_net'}
|
|
457 |
assert connect.call_args_list[0][1] == {'user': 'fred', 'dbname': 'tests_wcs_wcs_example_net'}
|
|
458 | 458 | |
459 | 459 |
pub.cfg['postgresql']['database-template-name'] = 'very_long_' * 10 + '%s' |
460 | 460 |
with mock.patch('psycopg2.connect') as connect: |
461 | 461 |
hobo_cmd.configure_sql(service, pub) |
462 |
assert connect.call_args_list[0][1] == {'user': 'test', 'database': 'postgres'}
|
|
462 |
assert connect.call_args_list[0][1] == {'user': 'test', 'dbname': 'postgres'}
|
|
463 | 463 |
assert connect.call_args_list[1][1] == { |
464 | 464 |
'user': 'fred', |
465 |
'database': 'very_long_very_long_very_long_c426_ng_very_long_wcs_example_net',
|
|
465 |
'dbname': 'very_long_very_long_very_long_c426_ng_very_long_wcs_example_net',
|
|
466 | 466 |
} |
467 |
assert len(connect.call_args_list[1][1]['database']) == 63
|
|
467 |
assert len(connect.call_args_list[1][1]['dbname']) == 63
|
|
468 | 468 |
assert pub.initialize_sql.call_count == 2 |
wcs/ctl/check_hobos.py | ||
---|---|---|
545 | 545 |
if v and isinstance(v, str): |
546 | 546 |
createdb_cfg[k] = v |
547 | 547 | |
548 |
if 'database' in createdb_cfg: |
|
549 |
createdb_cfg['dbname'] = createdb_cfg.pop('database') |
|
548 | 550 |
try: |
549 | 551 |
pgconn = psycopg2.connect(**createdb_cfg) |
550 | 552 |
except psycopg2.Error as e: |
wcs/ctl/delete_tenant.py | ||
---|---|---|
65 | 65 |
if not createdb_cfg: |
66 | 66 |
createdb_cfg = postgresql_cfg |
67 | 67 |
createdb = False |
68 |
if 'database' in createdb_cfg: |
|
69 |
createdb_cfg['dbname'] = createdb_cfg.pop('database') |
|
68 | 70 |
try: |
69 | 71 |
pgconn = psycopg2.connect(**createdb_cfg) |
70 | 72 |
except psycopg2.Error as e: |
wcs/sql.py | ||
---|---|---|
375 | 375 |
value = get_cfg('postgresql', {}).get(param) |
376 | 376 |
if value: |
377 | 377 |
postgresql_cfg[param] = value |
378 |
if 'database' in postgresql_cfg: |
|
379 |
postgresql_cfg['dbname'] = postgresql_cfg.pop('database') |
|
378 | 380 |
try: |
379 | 381 |
pgconn = psycopg2.connect(**postgresql_cfg) |
380 | 382 |
except psycopg2.Error: |
381 |
- |