This is an automated email from the ASF dual-hosted git repository.

vavila pushed a commit to branch fix/handle-oauth-updates
in repository https://gitbox.apache.org/repos/asf/superset.git


The following commit(s) were added to refs/heads/fix/handle-oauth-updates by 
this push:
     new 8a1f046546 Updating tests
8a1f046546 is described below

commit 8a1f046546a57575c094d2f75b0c47c4c1d6c098
Author: Vitor Avila <[email protected]>
AuthorDate: Fri Jan 10 00:56:58 2025 -0300

    Updating tests
---
 tests/unit_tests/commands/databases/update_test.py | 38 +++++++---------------
 1 file changed, 12 insertions(+), 26 deletions(-)

diff --git a/tests/unit_tests/commands/databases/update_test.py 
b/tests/unit_tests/commands/databases/update_test.py
index 637180fb12..4fab3bde49 100644
--- a/tests/unit_tests/commands/databases/update_test.py
+++ b/tests/unit_tests/commands/databases/update_test.py
@@ -21,6 +21,7 @@ import pytest
 from pytest_mock import MockerFixture
 
 from superset.commands.database.update import UpdateDatabaseCommand
+from superset.db_engine_specs.base import BaseEngineSpec
 from superset.exceptions import OAuth2RedirectError
 from superset.extensions import security_manager
 from superset.utils import json
@@ -83,7 +84,10 @@ def database_needs_oauth2(mocker: MockerFixture) -> 
MagicMock:
         "tab_id",
         "redirect_uri",
     )
-    database.get_oauth2_config.return_value = oauth2_client_info
+    database.encrypted_extra = json.dumps({"oauth2_client_info": 
oauth2_client_info})
+    database.db_engine_spec.unmask_encrypted_extra = (
+        BaseEngineSpec.unmask_encrypted_extra
+    )
 
     return database
 
@@ -333,14 +337,6 @@ def test_update_with_oauth2(
         "add_permission_view_menu",
     )
 
-    database_needs_oauth2.db_engine_spec.unmask_encrypted_extra.return_value = 
(
-        json.dumps(
-            {
-                "oauth2_client_info": oauth2_client_info,
-            }
-        )
-    )
-
     UpdateDatabaseCommand(1, {}).run()
 
     add_permission_view_menu.assert_not_called()
@@ -373,16 +369,14 @@ def test_update_with_oauth2_changed(
 
     modified_oauth2_client_info = oauth2_client_info.copy()
     modified_oauth2_client_info["scope"] = "scope-b"
-    database_needs_oauth2.db_engine_spec.unmask_encrypted_extra.return_value = 
(
-        json.dumps(
-            {
-                "oauth2_client_info": modified_oauth2_client_info,
-            }
-        )
-    )
 
     UpdateDatabaseCommand(
-        1, {"masked_encrypted_extra": json.dumps(modified_oauth2_client_info)}
+        1,
+        {
+            "masked_encrypted_extra": json.dumps(
+                {"oauth2_client_info": modified_oauth2_client_info}
+            )
+        },
     ).run()
 
     add_permission_view_menu.assert_not_called()
@@ -413,10 +407,6 @@ def test_remove_oauth_config_purges_tokens(
         "add_permission_view_menu",
     )
 
-    database_needs_oauth2.db_engine_spec.unmask_encrypted_extra.return_value = 
(
-        json.dumps({})
-    )
-
     UpdateDatabaseCommand(1, {"masked_encrypted_extra": None}).run()
 
     add_permission_view_menu.assert_not_called()
@@ -453,11 +443,7 @@ def test_update_other_fields_dont_affect_oauth(
         "add_permission_view_menu",
     )
 
-    database_needs_oauth2.db_engine_spec.unmask_encrypted_extra.return_value = 
(
-        json.dumps({})
-    )
-
     UpdateDatabaseCommand(1, {"database_name": "New DB name"}).run()
 
     add_permission_view_menu.assert_not_called()
-    database_needs_oauth2.purge_oauth2_tokens.assert_called()
+    database_needs_oauth2.purge_oauth2_tokens.assert_not_called()

Reply via email to