Skip to content

Commit 8d47474

Browse files
committed
removed mocker decorator from basic_test.py to fix travis python 3.x build issues
1 parent ecbf58c commit 8d47474

File tree

1 file changed

+49
-48
lines changed

1 file changed

+49
-48
lines changed

test/basic_test.py

Lines changed: 49 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -144,54 +144,55 @@ def test_load_logsearch_with_invalid_region():
144144
assert str(excinfo.value) == "Unrecognised region 'FR' valid regions are [EU, US, CA, AU]"
145145

146146

147-
@requests_mock.Mocker()
148147
def test_simple_query_when_lerest_returns_202_continuation(m):
149-
m.get(__API_KEY_URL,
150-
request_headers=__API_KEY_HEADER,
151-
json={'apikeys': [__LOG_ID]},
152-
status_code=200)
153-
154-
dummy_continuation_link_dict = {
155-
'rel': 'Self',
156-
'href': __SEARCH_QUERY_RESULTS_URL
157-
}
148+
with requests_mock.Mocker() as m:
149+
m.get(__API_KEY_URL,
150+
request_headers=__API_KEY_HEADER,
151+
json={'apikeys': [__LOG_ID]},
152+
status_code=200)
153+
154+
dummy_continuation_link_dict = {
155+
'rel': 'Self',
156+
'href': __SEARCH_QUERY_RESULTS_URL
157+
}
158158

159-
resp_body = {
160-
'events': [],
161-
'links': [dummy_continuation_link_dict,],
162-
'progress': 0
163-
}
159+
resp_body = {
160+
'events': [],
161+
'links': [dummy_continuation_link_dict,],
162+
'progress': 0
163+
}
164164

165-
m.post(__SEARCH_QUERY_URL,
166-
request_headers=__API_KEY_HEADER,
167-
status_code=202,
168-
json=resp_body)
169-
170-
m.get(__SEARCH_QUERY_RESULTS_URL, json=__SEARCH_QUERY_RESULTS_RESPONSE_JSON)
171-
172-
ls = LogSearch(api_key=__API_KEY)
173-
query = ls.search(query='where(main) calculate(count)',
174-
log_ids=[__LOG_ID],
175-
time_range='Last 24 Hours',
176-
limit=1)
177-
assert query.get_resp().json() == __SEARCH_QUERY_RESULTS_RESPONSE_JSON
178-
179-
@requests_mock.Mocker()
180-
def test_simple_query_when_lerest_returns_200_no_continuation(m):
181-
m.get(__API_KEY_URL,
182-
request_headers=__API_KEY_HEADER,
183-
json={'apikeys': [__LOG_ID]},
184-
status_code=200)
185-
186-
m.post(__SEARCH_QUERY_URL,
187-
request_headers=__API_KEY_HEADER,
188-
status_code=200,
189-
json=__SEARCH_QUERY_RESULTS_RESPONSE_JSON)
190-
191-
ls = LogSearch(api_key=__API_KEY)
192-
193-
query = ls.search(query='where(main) calculate(count)',
194-
log_ids=[__LOG_ID],
195-
time_range='Last 24 Hours',
196-
limit=1)
197-
assert query.get_resp().json() == __SEARCH_QUERY_RESULTS_RESPONSE_JSON
165+
m.post(__SEARCH_QUERY_URL,
166+
request_headers=__API_KEY_HEADER,
167+
status_code=202,
168+
json=resp_body)
169+
170+
m.get(__SEARCH_QUERY_RESULTS_URL, json=__SEARCH_QUERY_RESULTS_RESPONSE_JSON)
171+
172+
ls = LogSearch(api_key=__API_KEY)
173+
query = ls.search(query='where(main) calculate(count)',
174+
log_ids=[__LOG_ID],
175+
time_range='Last 24 Hours',
176+
limit=1)
177+
assert query.get_resp().json() == __SEARCH_QUERY_RESULTS_RESPONSE_JSON
178+
179+
180+
def test_simple_query_when_lerest_returns_200_no_continuation():
181+
with requests_mock.Mocker() as m:
182+
m.get(__API_KEY_URL,
183+
request_headers=__API_KEY_HEADER,
184+
json={'apikeys': [__LOG_ID]},
185+
status_code=200)
186+
187+
m.post(__SEARCH_QUERY_URL,
188+
request_headers=__API_KEY_HEADER,
189+
status_code=200,
190+
json=__SEARCH_QUERY_RESULTS_RESPONSE_JSON)
191+
192+
ls = LogSearch(api_key=__API_KEY)
193+
194+
query = ls.search(query='where(main) calculate(count)',
195+
log_ids=[__LOG_ID],
196+
time_range='Last 24 Hours',
197+
limit=1)
198+
assert query.get_resp().json() == __SEARCH_QUERY_RESULTS_RESPONSE_JSON

0 commit comments

Comments
 (0)