convert to sql: add [options] section if it doesn't exist (#27987)
This commit is contained in:
parent
a5203ec083
commit
16571e6ff8
|
@ -65,7 +65,7 @@ def test_command_exists():
|
|||
assert 'convert_to_sql' in get_commands()
|
||||
|
||||
|
||||
def test_unknown_publisher_fails():
|
||||
def test_unknown_publisher_fails(pub):
|
||||
with pytest.raises(CommandError) as excinfo:
|
||||
call_command('convert_to_sql', '-d', 'unknown.net', '--database', 'foobar')
|
||||
assert excinfo.value.message == 'unknown tenant'
|
||||
|
|
|
@ -57,9 +57,9 @@ class Command(BaseCommand):
|
|||
|
||||
def get_publisher(self, domain):
|
||||
publisher_class = get_publisher_class()
|
||||
publisher = publisher_class.create_publisher()
|
||||
if domain not in publisher.get_tenants():
|
||||
if domain not in publisher_class.get_tenants():
|
||||
raise CommandError('unknown tenant')
|
||||
publisher = publisher_class.create_publisher()
|
||||
|
||||
publisher.app_dir = os.path.join(publisher.app_dir, domain)
|
||||
publisher.set_config()
|
||||
|
@ -74,6 +74,8 @@ class Command(BaseCommand):
|
|||
|
||||
def enable_connection(self):
|
||||
if not self.publisher.site_options.has_option('options', 'postgresql'):
|
||||
if not self.publisher.site_options.has_section('options'):
|
||||
self.publisher.site_options.add_section('options')
|
||||
self.publisher.site_options.set('options', 'postgresql', 'true')
|
||||
options_file = os.path.join(self.publisher.app_dir, 'site-options.cfg')
|
||||
stringio = StringIO.StringIO()
|
||||
|
|
Loading…
Reference in New Issue