Browse Source

[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 months ago
parent
commit
666cf4e6c6

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

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

File diff suppressed because it is too large
+ 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.auth.backend import is_admin
 from desktop.conf import (
 from desktop.conf import (
   APP_BLACKLIST,
   APP_BLACKLIST,
-  COLLECT_USAGE,
   DISABLE_SOURCE_AUTOCOMPLETE,
   DISABLE_SOURCE_AUTOCOMPLETE,
   ENABLE_NEW_IMPORTER,
   ENABLE_NEW_IMPORTER,
   ENABLE_NEW_STORAGE_BROWSER,
   ENABLE_NEW_STORAGE_BROWSER,
   ENABLE_ORGANIZATIONS,
   ENABLE_ORGANIZATIONS,
-  ENABLE_SHARING,
   ENABLE_UNIFIED_ANALYTICS,
   ENABLE_UNIFIED_ANALYTICS,
   get_clusters,
   get_clusters,
   has_connectors,
   has_connectors,
@@ -1803,11 +1801,6 @@ class ClusterConfig(object):
       'default_sql_interpreter': default_sql_interpreter,
       'default_sql_interpreter': default_sql_interpreter,
       'cluster_type': self.cluster_type,
       'cluster_type': self.cluster_type,
       'has_computes': self.cluster_type in ('cdw', 'altus', 'snowball'),  # or any grouped engine connectors
       '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,
       'vw_name': hue_host_name,
       'img_version': img_version,
       'img_version': img_version,
       'hue_version': version_of_hue
       'hue_version': version_of_hue

Some files were not shown because too many files changed in this diff