def test_customized_values(self): expected_settings = { 'jujugui.api_path': 'v4', 'jujugui.auth': 'blob', 'jujugui.base_url': '/another/url', 'jujugui.charmstore_url': 'https://1.2.3.4/api/', 'jujugui.combine': True, 'jujugui.GTM_enabled': True, 'jujugui.gzip': False, 'jujugui.interactive_login': False, 'jujugui.jem_url': 'http://1.2.3.4:8082', 'jujugui.password': '******', 'jujugui.raw': False, 'jujugui.sandbox': True, 'jujugui.socketTemplate': '/juju/api/$host/$port/$uuid', 'jujugui.user': '******', } settings = { 'jujugui.api_path': 'v4', 'jujugui.auth': 'blob', 'jujugui.base_url': '/another/url', 'jujugui.charmstore_url': 'https://1.2.3.4/api/', 'jujugui.combine': 'true', 'jujugui.GTM_enabled': True, 'jujugui.gzip': 'false', 'jujugui.interactive_login': '******', 'jujugui.jem_url': 'http://1.2.3.4:8082', 'jujugui.password': '******', 'jujugui.raw': 'off', 'jujugui.sandbox': 'on', 'jujugui.socketTemplate': '/juju/api/$host/$port/$uuid', 'jujugui.user': '******', } options.update(settings) self.assertEqual(expected_settings, settings)
def test_customized_values(self): expected_settings = { 'jujugui.auth': 'blob', 'jujugui.base_url': '/another/url/', 'jujugui.bundleservice_url': 'https://1.2.3.4/bundleservice/', 'jujugui.charmstore_url': 'https://1.2.3.4/api/', 'jujugui.combine': True, 'jujugui.gisf': True, 'jujugui.GTM_enabled': True, 'jujugui.gzip': False, 'jujugui.insecure': True, 'jujugui.interactive_login': False, 'jujugui.password': '******', 'jujugui.plans_url': 'https://1.2.3.4/plans-api/', 'jujugui.raw': False, 'jujugui.apiAddress': 'wss://api.address', 'jujugui.jujushellURL': 'wss://juju.shell', 'jujugui.controllerSocketTemplate': '/my-api', 'jujugui.socketTemplate': '/juju/api/$host/$port/$uuid', 'jujugui.static_url': '/horizon/juju', 'jujugui.stats_url': '/_stats', 'jujugui.stripe_key': '123', 'jujugui.payment_url': 'https://1.2.3.4/payment-api/', 'jujugui.rates_url': 'https://1.2.3.4/rates-api/', 'jujugui.terms_url': 'https://1.2.3.4/terms-api/', 'jujugui.user': '******', 'jujugui.flags': {'foo': True} } settings = { 'jujugui.auth': 'blob', 'jujugui.base_url': '/another/url', 'jujugui.bundleservice_url': 'https://1.2.3.4/bundleservice', 'jujugui.charmstore_url': 'https://1.2.3.4/api/', 'jujugui.combine': 'true', 'jujugui.gisf': True, 'jujugui.GTM_enabled': True, 'jujugui.gzip': 'false', 'jujugui.insecure': True, 'jujugui.interactive_login': '******', 'jujugui.password': '******', 'jujugui.plans_url': 'https://1.2.3.4/plans-api/', 'jujugui.raw': 'off', 'jujugui.apiAddress': 'wss://api.address', 'jujugui.jujushellURL': 'wss://juju.shell', 'jujugui.controllerSocketTemplate': '/my-api', 'jujugui.socketTemplate': '/juju/api/$host/$port/$uuid', 'jujugui.static_url': '/horizon/juju', 'jujugui.stats_url': '/_stats', 'jujugui.stripe_key': '123', 'jujugui.payment_url': 'https://1.2.3.4/payment-api/', 'jujugui.rates_url': 'https://1.2.3.4/rates-api/', 'jujugui.terms_url': 'https://1.2.3.4/terms-api/', 'jujugui.user': '******', 'jujugui.flags': {'foo': True} } options.update(settings) self.assertEqual(expected_settings, settings)
def test_customized_values(self): expected_settings = { 'jujugui.auth': 'blob', 'jujugui.base_url': '/another/url/', 'jujugui.bundleservice_url': 'https://1.2.3.4/bundleservice/', 'jujugui.charmstore_url': 'https://1.2.3.4/api/', 'jujugui.combine': True, 'jujugui.gisf': True, 'jujugui.GTM_enabled': True, 'jujugui.gzip': False, 'jujugui.insecure': True, 'jujugui.interactive_login': False, 'jujugui.password': '******', 'jujugui.plans_url': 'https://1.2.3.4/plans-api/', 'jujugui.raw': False, 'jujugui.apiAddress': 'wss://api.address', 'jujugui.controllerSocketTemplate': '/my-api', 'jujugui.socketTemplate': '/juju/api/$host/$port/$uuid', 'jujugui.static_url': '/horizon/juju', 'jujugui.stats_url': '/_stats', 'jujugui.stripe_key': '123', 'jujugui.payment_url': 'https://1.2.3.4/payment-api/', 'jujugui.terms_url': 'https://1.2.3.4/terms-api/', 'jujugui.user': '******', 'jujugui.flags': {'foo': True} } settings = { 'jujugui.auth': 'blob', 'jujugui.base_url': '/another/url', 'jujugui.bundleservice_url': 'https://1.2.3.4/bundleservice', 'jujugui.charmstore_url': 'https://1.2.3.4/api/', 'jujugui.combine': 'true', 'jujugui.gisf': True, 'jujugui.GTM_enabled': True, 'jujugui.gzip': 'false', 'jujugui.insecure': True, 'jujugui.interactive_login': '******', 'jujugui.password': '******', 'jujugui.plans_url': 'https://1.2.3.4/plans-api/', 'jujugui.raw': 'off', 'jujugui.apiAddress': 'wss://api.address', 'jujugui.controllerSocketTemplate': '/my-api', 'jujugui.socketTemplate': '/juju/api/$host/$port/$uuid', 'jujugui.static_url': '/horizon/juju', 'jujugui.stats_url': '/_stats', 'jujugui.stripe_key': '123', 'jujugui.payment_url': 'https://1.2.3.4/payment-api/', 'jujugui.terms_url': 'https://1.2.3.4/terms-api/', 'jujugui.user': '******', 'jujugui.flags': {'foo': True} } options.update(settings) self.assertEqual(expected_settings, settings)
def gui(config): options.update(config.registry.settings) # We use regex separators for the prefix and file sections of the # jujugui.ui route to make sure we capture *everything* before the # static/gui/build/app section and get the file path as one string # rather than several separated by "/". config.add_route("jujugui.ui", "/{prefix:.*}static/gui/build/app/{file:.*}") config.add_route("jujugui.config", "/config.js") config.add_route("jujugui.version", "/version") config.add_route("jujugui.convoy", "/{cachebuster}/combo") js_files = _APP_DIR + "/static/gui/build" headers = [("Cache-Control", "max-age=3600, public")] application = combo_app(js_files, additional_headers=headers) config.add_view(wsgiapp2(application), route_name="jujugui.convoy") config.add_route("jujugui.app", "/*state") config.include("pyramid_mako") config.add_renderer("prettyjson", JSON(indent=4)) config.scan("jujugui.views")
def gui(config): options.update(config.registry.settings) # We use regex separators for the prefix and file sections of the # jujugui.ui route to make sure we capture *everything* before the # juju-ui section and get the file path as one string rather than # several separated by "/". config.add_route('jujugui.ui', '/{prefix:.*}juju-ui/{file:.*}') config.add_route('jujugui.config', '/config.js') config.add_route('jujugui.version', '/version') config.add_route('jujugui.convoy', '/{cachebuster}/combo') js_files = _APP_DIR + '/static/gui/build' headers = [('Cache-Control', 'max-age=3600, public')] application = combo_app(js_files, additional_headers=headers) config.add_view(wsgiapp2(application), route_name='jujugui.convoy') config.add_route('jujugui.app', '/*state') config.include('pyramid_mako') config.add_renderer('prettyjson', JSON(indent=4)) config.scan('jujugui.views')
def test_customized_values(self): expected_settings = { 'jujugui.auth': 'blob', 'jujugui.base_url': '/another/url', 'jujugui.charmstore_url': 'https://1.2.3.4/api/', 'jujugui.combine': True, 'jujugui.gisf': True, 'jujugui.GTM_enabled': True, 'jujugui.gzip': False, 'jujugui.insecure': True, 'jujugui.interactive_login': False, 'jujugui.jem_url': 'http://1.2.3.4:8082', 'jujugui.password': '******', 'jujugui.plans_url': 'https://1.2.3.4/plans-api/', 'jujugui.raw': False, 'jujugui.sandbox': True, 'jujugui.socketTemplate': '/juju/api/$host/$port/$uuid', 'jujugui.terms_url': 'https://1.2.3.4/terms-api/', 'jujugui.user': '******', } settings = { 'jujugui.auth': 'blob', 'jujugui.base_url': '/another/url', 'jujugui.charmstore_url': 'https://1.2.3.4/api/', 'jujugui.combine': 'true', 'jujugui.gisf': True, 'jujugui.GTM_enabled': True, 'jujugui.gzip': 'false', 'jujugui.insecure': True, 'jujugui.interactive_login': '******', 'jujugui.jem_url': 'http://1.2.3.4:8082', 'jujugui.password': '******', 'jujugui.plans_url': 'https://1.2.3.4/plans-api/', 'jujugui.raw': 'off', 'jujugui.sandbox': 'on', 'jujugui.socketTemplate': '/juju/api/$host/$port/$uuid', 'jujugui.terms_url': 'https://1.2.3.4/terms-api/', 'jujugui.user': '******', } options.update(settings) self.assertEqual(expected_settings, settings)
def test_none_returned(self): self.assertIsNone(options.update({}))
def test_empty_values(self): settings = dict((k, '') for k in self.default_settings) options.update(settings) defaults = deepcopy(self.default_settings) self.assertEqual(defaults, settings)
def test_default_values(self): settings = {} options.update(settings) defaults = deepcopy(self.default_settings) self.assertEqual(defaults, settings)
def test_false_non_defaults(self): settings = {'jujugui.gzip': False} options.update(settings) self.assertFalse(settings['jujugui.gzip'])