Skip to content

Commit ea7598f

Browse files
committed
test: fix test cases
1 parent b2b211f commit ea7598f

File tree

3 files changed

+14
-7
lines changed

3 files changed

+14
-7
lines changed

qiniu/http/regions_provider.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,8 @@ def __iter__(self):
524524
self.__get_regions_from_base_provider
525525
]
526526

527-
regions = []
527+
# set the fallback to None for raise errors when failed
528+
regions = None
528529
for get_regions in get_regions_fns:
529530
regions = get_regions(fallback=regions)
530531
if regions and all(r.is_live for r in regions):

tests/cases/test_http/test_regions_provider.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,13 @@ def test_shrink_with_expired_regions(self, cached_regions_provider):
275275
origin_cache_key = cached_regions_provider.cache_key
276276
cached_regions_provider.set_regions([expired_region])
277277
cached_regions_provider.cache_key = 'another-cache-key'
278-
list(cached_regions_provider) # trigger __shrink_cache()
278+
279+
# trigger __shrink_cache()
280+
cached_regions_provider._cache_scope = cached_regions_provider._cache_scope._replace(
281+
last_shrink_at=datetime.datetime.fromtimestamp(0)
282+
)
283+
list(cached_regions_provider)
284+
279285
assert len(cached_regions_provider._cache_scope.memo_cache[origin_cache_key]) == 0
280286

281287
def test_shrink_with_ignore_expired_regions(self, cached_regions_provider):

tests/cases/test_zone/test_qiniu_conf.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def test_config_compatible(self, set_conf_default):
5151
'set_conf_default',
5252
[
5353
{
54-
'default_query_region_host': 'https://fake-uc.phpsdk.qiniu.com'
54+
'default_query_region_host': 'https://fake-uc.pysdk.qiniu.com'
5555
}
5656
],
5757
indirect=True
@@ -66,9 +66,9 @@ def test_query_region_with_custom_domain(self, access_key, bucket_name, set_conf
6666
'set_conf_default',
6767
[
6868
{
69-
'default_query_region_host': 'https://fake-uc.phpsdk.qiniu.com',
69+
'default_query_region_host': 'https://fake-uc.pysdk.qiniu.com',
7070
'default_query_region_backup_hosts': [
71-
'unavailable-uc.phpsdk.qiniu.com',
71+
'unavailable-uc.pysdk.qiniu.com',
7272
'uc.qbox.me'
7373
]
7474
}
@@ -78,13 +78,13 @@ def test_query_region_with_custom_domain(self, access_key, bucket_name, set_conf
7878
def test_query_region_with_backup_domains(self, access_key, bucket_name, set_conf_default):
7979
zone = Zone()
8080
data = zone.bucket_hosts(access_key, bucket_name)
81-
assert data != 'null'
81+
assert data != 'null' and len(data) > 0
8282

8383
@pytest.mark.parametrize(
8484
'set_conf_default',
8585
[
8686
{
87-
'default_uc_host': 'https://fake-uc.phpsdk.qiniu.com',
87+
'default_uc_host': 'https://fake-uc.pysdk.qiniu.com',
8888
'default_query_region_backup_hosts': [
8989
'unavailable-uc.phpsdk.qiniu.com',
9090
'uc.qbox.me'

0 commit comments

Comments
 (0)