Skip to content

Commit e0c5569

Browse files
tests: use re.search instead of re.match
1 parent 8841765 commit e0c5569

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

tests/helpers.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,21 @@
66
from faker import Faker
77

88

9+
def check_credentials():
10+
credentials = [
11+
'ALGOLIA_APPLICATION_ID',
12+
'ALGOLIA_API_KEY',
13+
'ALGOLIA_API_KEY_SEARCH',
14+
'ALGOLIA_APPLICATION_ID_MCM',
15+
'ALGOLIA_API_KEY_MCM'
16+
]
17+
18+
for credential in credentials:
19+
if credential not in os.environ:
20+
print('environement variable {} not defined')
21+
assert False
22+
23+
924
def index_name():
1025
name = 'algolia-python{}'.format(randint(1, 100000))
1126

@@ -64,6 +79,7 @@ def create_client(
6479
'urlfetch', urlfetch_stub.URLFetchServiceStub()
6580
)
6681

82+
check_credentials()
6783
try:
6884
return algoliasearch.Client(
6985
os.environ[app_id_env],

tests/test_client.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from algoliasearch.client import RequestOptions, MAX_API_KEY_LENGTH, Client
55
from algoliasearch.helpers import AlgoliaException
66
from fake_session import FakeSession
7-
from helpers import Factory
7+
from helpers import Factory, check_credentials
88

99

1010
def test_request_options(client):
@@ -105,6 +105,7 @@ def user_name(self):
105105

106106

107107
def test_dns_timeout():
108+
check_credentials()
108109
app_id = os.environ['ALGOLIA_APPLICATION_ID']
109110

110111
hosts = ['algolia.biz']
@@ -124,6 +125,7 @@ def test_dns_timeout():
124125

125126

126127
def test_dns_timeout_hard():
128+
check_credentials()
127129
app_id = os.environ['ALGOLIA_APPLICATION_ID']
128130

129131
hosts = ['algolia.biz', '%s-dsn.algolia.net' % app_id]

tests/test_index.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ def test_search(ro_index):
388388

389389
res = ro_index.search('', {'analytics': False})
390390
assert res['nbHits'] == 5
391-
assert re.match(r'analytics=false', res['params'])
391+
assert re.search(r'analytics=false', res['params'])
392392

393393
res = ro_index.search(ro_index.data[2]['name'][0])
394394
assert res['nbHits'] >= 1

0 commit comments

Comments
 (0)