浏览代码

[api][conf] Refactor API tests and configuration handling (#4181)

- Enhanced the configuration retrieval in the API to include new flags for sharing and usage collection. This fixes bug of hue_config present ClusterConfig getting overridden.
- Removed redundant configuration entries from the ClusterConfig model.
- Reorganized import statements for consistency and clarity.
- Updated test cases to check for all config fields, improve readability and maintainability, including adjustments to JSON handling and assertions.
Harsh Gupta 5 月之前
父节点
当前提交
666cf4e6c6
共有 3 个文件被更改,包括 328 次插入293 次删除
  1. 3 0
      desktop/core/src/desktop/api2.py
  2. 325 286
      desktop/core/src/desktop/api2_tests.py
  3. 0 7
      desktop/core/src/desktop/models.py

+ 3 - 0
desktop/core/src/desktop/api2.py

@@ -41,6 +41,7 @@ from beeswax.models import Namespace
 from desktop import appmanager
 from desktop.auth.backend import is_admin
 from desktop.conf import (
+  COLLECT_USAGE,
   CUSTOM,
   ENABLE_CHUNKED_FILE_UPLOADER,
   ENABLE_CONNECTORS,
@@ -148,6 +149,8 @@ def get_config(request):
     'enable_task_server': TASK_SERVER_V2.ENABLED.get(),
     'enable_workflow_creation_action': ENABLE_WORKFLOW_CREATION_ACTION.get(),
     'allow_sample_data_from_views': ALLOW_SAMPLE_DATA_FROM_VIEWS.get(),
+    'enable_sharing': ENABLE_SHARING.get(),
+    'collect_usage': COLLECT_USAGE.get(),
   }
 
   # Storage browser configuration

文件差异内容过多而无法显示
+ 325 - 286
desktop/core/src/desktop/api2_tests.py


+ 0 - 7
desktop/core/src/desktop/models.py

@@ -40,12 +40,10 @@ from desktop import appmanager
 from desktop.auth.backend import is_admin
 from desktop.conf import (
   APP_BLACKLIST,
-  COLLECT_USAGE,
   DISABLE_SOURCE_AUTOCOMPLETE,
   ENABLE_NEW_IMPORTER,
   ENABLE_NEW_STORAGE_BROWSER,
   ENABLE_ORGANIZATIONS,
-  ENABLE_SHARING,
   ENABLE_UNIFIED_ANALYTICS,
   get_clusters,
   has_connectors,
@@ -1803,11 +1801,6 @@ class ClusterConfig(object):
       'default_sql_interpreter': default_sql_interpreter,
       'cluster_type': self.cluster_type,
       'has_computes': self.cluster_type in ('cdw', 'altus', 'snowball'),  # or any grouped engine connectors
-      'hue_config': {
-        'enable_sharing': ENABLE_SHARING.get(),
-        'collect_usage': COLLECT_USAGE.get()
-      },
-      'storage_browser': {},
       'vw_name': hue_host_name,
       'img_version': img_version,
       'hue_version': version_of_hue

部分文件因为文件数量过多而无法显示