def test_get_setting_type_from_setting_invalid_setting(self): not_a_setting = mock.MagicMock() with self.assertRaises(RuntimeError) as cm: install_commands.get_setting_type_from_setting(not_a_setting) self.assertIn('Could not determine setting type for setting:', str(cm.exception))
def process_settings(app_instance, app_py_path, channel_layer): app_settings = get_app_settings(app_instance.package) # In the case the app isn't installed, has no settings, or it is an extension, # skip configuring services/settings if not app_settings: send_notification("No Services found to configure.", channel_layer) return unlinked_settings = app_settings['unlinked_settings'] services = [] for setting in unlinked_settings: if setting.__class__.__name__ == "CustomSetting": continue service_type = get_service_type_from_setting(setting) newSetting = { "name": setting.name, "required": setting.required, "description": setting.description, "service_type": service_type, "setting_type": get_setting_type_from_setting(setting), "options": get_service_options(service_type) } services.append(newSetting) get_data_json = { "data": services, "returnMethod": "configure_services", "jsHelperFunction": "processServices", "app_py_path": app_py_path, "current_app_name": app_instance.package } send_notification(get_data_json, channel_layer)
def test_get_setting_type_from_setting_wps(self): from tethys_apps.models import WebProcessingServiceSetting with transaction.atomic(): setting = WebProcessingServiceSetting.objects.create( name='fake_sds', description='The fake spatial dataset service.', required=False, tethys_app=self.app) ret = install_commands.get_setting_type_from_setting(setting) self.assertEqual('wps', ret)
def test_get_setting_type_from_setting_persistent_connection(self): from tethys_apps.models import PersistentStoreConnectionSetting with transaction.atomic(): setting = PersistentStoreConnectionSetting.objects.create( name='fake_conn', description='The fake database connection.', required=False, tethys_app=self.app) ret = install_commands.get_setting_type_from_setting(setting) self.assertEqual('ps_connection', ret)
def test_get_setting_type_from_setting_dataset(self): from tethys_apps.models import DatasetServiceSetting with transaction.atomic(): setting = DatasetServiceSetting.objects.create( name='fake_ds', description='The fake CKAN dataset service.', engine=DatasetServiceSetting.CKAN, required=False, tethys_app=self.app) ret = install_commands.get_setting_type_from_setting(setting) self.assertEqual('ds_dataset', ret)
def test_get_setting_type_from_setting_spatial_dataset(self): from tethys_apps.models import SpatialDatasetServiceSetting with transaction.atomic(): setting = SpatialDatasetServiceSetting.objects.create( name='fake_sds', description='The fake GeoServer dataset service.', engine=SpatialDatasetServiceSetting.GEOSERVER, required=False, tethys_app=self.app) ret = install_commands.get_setting_type_from_setting(setting) self.assertEqual('ds_spatial', ret)
def test_get_setting_type_from_setting_persistent_db(self): from tethys_apps.models import PersistentStoreDatabaseSetting with transaction.atomic(): setting = PersistentStoreDatabaseSetting.objects.create( name='fake_db', description='The fake database.', initializer='fake.path.to.initializer', spatial=False, required=False, tethys_app=self.app) ret = install_commands.get_setting_type_from_setting(setting) self.assertEqual('ps_database', ret)