Jelajahi Sumber

HUE-1248 [core] Incorrect message in 'About Hue' screen

- Update dump_config and check_config to use HUE_CONF_DIR env. var.
Abraham Elmahrek 12 tahun lalu
induk
melakukan
35af9d3912
2 mengubah file dengan 14 tambahan dan 2 penghapusan
  1. 12 0
      desktop/core/src/desktop/tests.py
  2. 2 2
      desktop/core/src/desktop/views.py

+ 12 - 0
desktop/core/src/desktop/tests.py

@@ -20,6 +20,7 @@ import desktop
 import desktop.urls
 import desktop.conf
 import logging
+import os
 import time
 
 import desktop.views as views
@@ -138,6 +139,11 @@ def test_dump_config():
   response = client_not_me.get('/dump_config')
   assert_equal("You must be a superuser.", response.content)
 
+  os.environ["HUE_CONF_DIR"] = "/tmp/test_hue_conf_dir"
+  resp = c.get('/dump_config')
+  del os.environ["HUE_CONF_DIR"]
+  assert_true('/tmp/test_hue_conf_dir' in resp.content, resp)
+
 
 def test_prefs():
   c = make_logged_in_client()
@@ -409,6 +415,12 @@ def test_config_check():
     assert_true('klingon' in resp.content, resp)
     assert_true('Encoding not supported' in resp.content, resp)
 
+    # Set HUE_CONF_DIR and make sure check_config returns appropriate conf
+    os.environ["HUE_CONF_DIR"] = "/tmp/test_hue_conf_dir"
+    resp = cli.get('/debug/check_config')
+    del os.environ["HUE_CONF_DIR"]
+    assert_true('/tmp/test_hue_conf_dir' in resp.content, resp)
+
     # Alert present in the status bar
     resp = cli.get('/about', follow=True)
     assert_true('misconfiguration' in resp.content, resp.content)

+ 2 - 2
desktop/core/src/desktop/views.py

@@ -182,7 +182,7 @@ def status_bar(request):
 def dump_config(request):
   # Note that this requires login (as do most apps).
   show_private = False
-  conf_dir = os.path.realpath(get_desktop_root('conf'))
+  conf_dir = os.path.realpath(os.getenv("HUE_CONF_DIR", get_desktop_root("conf")))
 
   if not request.user.is_superuser:
     return HttpResponse(_("You must be a superuser."))
@@ -369,7 +369,7 @@ def check_config(request):
   if not request.user.is_superuser:
     return HttpResponse(_("You must be a superuser."))
 
-  conf_dir = os.path.realpath(get_desktop_root('conf'))
+  conf_dir = os.path.realpath(os.getenv("HUE_CONF_DIR", get_desktop_root("conf")))
   return render('check_config.mako', request, dict(
                     error_list=_get_config_errors(cache=False),
                     conf_dir=conf_dir))