Skip to content

Commit ad3e281

Browse files
Fix the test on the DNS timeout for it to legitimately fail
1 parent e85e295 commit ad3e281

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

tests/test_client.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import unittest
1313

1414
from algoliasearch.client import Client, MAX_API_KEY_LENGTH
15+
from algoliasearch.helpers import AlgoliaException
1516

1617
from .helpers import safe_index_name
1718
from .helpers import get_api_client
@@ -123,20 +124,16 @@ def user_name(self):
123124
def test_dns_timeout(self):
124125
app_id = os.environ['ALGOLIA_APPLICATION_ID']
125126

126-
hosts = [
127-
'%s-dsn.algolia.biz' % app_id,
128-
'%s-dsn.algolia.net' % app_id,
129-
'%s-1.algolianet.com' % app_id,
130-
'%s-2.algolianet.com' % app_id,
131-
'%s-3.algolianet.com' % app_id,
132-
]
133-
127+
hosts = ['algolia.biz']
134128
client = Client(app_id, os.environ['ALGOLIA_API_KEY'], hosts)
135129
client.set_timeout(5, 2)
136130

137131
now = time.time()
138-
indices = client.list_indexes()
139-
self.assertLess(now + 5, time.time())
132+
try:
133+
indices = client.list_indexes()
134+
except AlgoliaException:
135+
pass
136+
self.assertLess(time.time(), now + 6)
140137

141138

142139
class ClientWithDataTest(ClientTest):

0 commit comments

Comments
 (0)