Эх сурвалжийг харах

HUE-6780 [aws] Fix tests for empty configurations

Jenny Kim 8 жил өмнө
parent
commit
44b8451

+ 7 - 10
desktop/libs/aws/src/aws/s3/s3_test.py

@@ -74,7 +74,7 @@ def test_s3datetime_to_timestamp():
 
 
 def test_get_default_region():
 def test_get_default_region():
   # Verify that Hue can infer region from subdomain hosts
   # Verify that Hue can infer region from subdomain hosts
-  finish = conf.AWS_ACCOUNTS['default'].HOST.set_for_testing('s3.ap-northeast-2.amazonaws.com')
+  finish = conf.AWS_ACCOUNTS.set_for_testing({'default': {'host': 's3.ap-northeast-2.amazonaws.com'}})
   try:
   try:
     assert_equal('ap-northeast-2', get_default_region())
     assert_equal('ap-northeast-2', get_default_region())
   finally:
   finally:
@@ -82,7 +82,7 @@ def test_get_default_region():
       finish()
       finish()
 
 
   # Verify that Hue can infer region from hyphenated hosts
   # Verify that Hue can infer region from hyphenated hosts
-  finish = conf.AWS_ACCOUNTS['default'].HOST.set_for_testing('s3-ap-south-1.amazonaws.com')
+  finish = conf.AWS_ACCOUNTS.set_for_testing({'default': {'host': 's3-ap-south-1.amazonaws.com'}})
   try:
   try:
     assert_equal('ap-south-1', get_default_region())
     assert_equal('ap-south-1', get_default_region())
   finally:
   finally:
@@ -90,7 +90,7 @@ def test_get_default_region():
       finish()
       finish()
 
 
   # Verify that Hue can infer region from hyphenated hosts
   # Verify that Hue can infer region from hyphenated hosts
-  finish = conf.AWS_ACCOUNTS['default'].HOST.set_for_testing('s3.dualstack.ap-southeast-2.amazonaws.com')
+  finish = conf.AWS_ACCOUNTS.set_for_testing({'default': {'host': 's3.dualstack.ap-southeast-2.amazonaws.com'}})
   try:
   try:
     assert_equal('ap-southeast-2', get_default_region())
     assert_equal('ap-southeast-2', get_default_region())
   finally:
   finally:
@@ -98,7 +98,7 @@ def test_get_default_region():
       finish()
       finish()
 
 
   # Verify that Hue falls back to the default if the region is not valid
   # Verify that Hue falls back to the default if the region is not valid
-  finish = conf.AWS_ACCOUNTS['default'].HOST.set_for_testing('s3-external-1.amazonaws.com')
+  finish = conf.AWS_ACCOUNTS.set_for_testing({'default': {'host': 's3-external-1.amazonaws.com'}})
   try:
   try:
     assert_equal(Location.DEFAULT, get_default_region())
     assert_equal(Location.DEFAULT, get_default_region())
   finally:
   finally:
@@ -106,12 +106,9 @@ def test_get_default_region():
       finish()
       finish()
 
 
   # Verify that Hue uses the region if specified
   # Verify that Hue uses the region if specified
-  finish = [
-    conf.AWS_ACCOUNTS['default'].HOST.set_for_testing(''),
-    conf.AWS_ACCOUNTS['default'].REGION.set_for_testing('ca-central-1'),
-  ]
+  finish = conf.AWS_ACCOUNTS.set_for_testing({'default': {'host': '', 'region': 'ca-central-1'}})
   try:
   try:
     assert_equal('ca-central-1', get_default_region())
     assert_equal('ca-central-1', get_default_region())
   finally:
   finally:
-    for reset in finish:
-      reset()
+    if finish:
+      finish()