Commit 93717b90 by John Eskew

Add --devstack param to whitelabel setup mgmt cmd.

parent 6badee49
......@@ -23,6 +23,7 @@ class Command(BaseCommand):
help = 'Creates Sites, SiteThemes, SiteConfigurations and partners.'
dns_name = None
theme_path = None
configuration_filename = None
def add_arguments(self, parser):
parser.add_argument(
......@@ -39,6 +40,12 @@ class Command(BaseCommand):
required=True
)
parser.add_argument(
"--devstack",
action='store_true',
help="Use devstack config, otherwise sandbox config is assumed",
)
def _create_sites(self, site_domain, theme_dir_name, site_configuration, partner_code):
"""
Create Sites, SiteThemes and SiteConfigurations
......@@ -85,7 +92,7 @@ class Command(BaseCommand):
Reads the json files from theme directory and returns the site partner data in JSON format.
"""
site_data = {}
for config_file in self.find('sandbox_configuration.json', self.theme_path):
for config_file in self.find(self.configuration_filename, self.theme_path):
logger.info('Reading file from %s', config_file)
configuration_data = json.loads(
json.dumps(
......@@ -104,9 +111,16 @@ class Command(BaseCommand):
return site_data
def handle(self, *args, **options):
if options['devstack']:
configuration_prefix = 'devstack'
else:
configuration_prefix = 'sandbox'
self.configuration_filename = '{}_configuration.json'.format(configuration_prefix)
self.dns_name = options['dns_name']
self.theme_path = options['theme_path']
logger.info("Using %s configuration...", configuration_prefix)
logger.info('DNS name: %s', self.dns_name)
logger.info('Theme path: %s', self.theme_path)
......
{
"ecommerce_configuration":{
"site_partner": "dummy",
"theme_dir_name": "dummy.dir",
"site_domain": "ecommerce-dummy-{dns_name}.example.com",
"configuration": {
"lms_url_root": "https://dummy-{dns_name}.example.com",
"payment_processors": "dummy-method",
"client_side_payment_processor": "dummy-method",
"enable_enrollment_codes": true,
"oauth_settings": {
"dummy-key": "dummy-value"
},
"payment_support_email": "dummy@example.com",
"payment_support_url": "https://dummy-{dns_name}.example.com/contact",
"discovery_api_url": "https://discovery-dummy-{dns_name}.example.com/api/v1/"
}
}
}
......@@ -106,6 +106,18 @@ class TestCreateSitesAndPartners(TestCase):
"--theme-path", self.theme_path,
)
def test_create_devstack_site_and_partner(self):
"""
Verify that command creates sites and Partners
"""
call_command(
"create_sites_and_partners",
"--dns-name", self.dns_name,
"--theme-path", self.theme_path,
"--devstack"
)
self._assert_sites_data_is_valid()
def test_create_site_and_partner(self):
"""
Verify that command creates sites and Partners
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment