Skip to content

Commit ed8c475

Browse files
authored
Merge pull request #75 from JaviCerveraIngram/CPS-53-timeout
Cps 53 timeout
2 parents 42672b6 + 59ba47d commit ed8c475

File tree

5 files changed

+21
-5
lines changed

5 files changed

+21
-5
lines changed

connect/resources/base.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@ def _fix_request_kwargs(self, path, prev_kwargs, **kwargs):
9090
fixed_kwargs['url'] = self.get_url(path)
9191
if 'headers' not in fixed_kwargs:
9292
fixed_kwargs['headers'] = self.headers
93+
if 'timeout' not in fixed_kwargs:
94+
fixed_kwargs['timeout'] = 300
9395
return fixed_kwargs
9496

9597
@staticmethod

tests/test_conversation.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ def test_add_message(post_mock):
5757
post_mock.assert_called_with(
5858
headers={'Content-Type': 'application/json', 'Authorization': 'ApiKey XXXX:YYYYY'},
5959
json={'text': text},
60+
timeout=300,
6061
url='http://localhost:8080/api/public/v1/conversations/CO-750-033-356/messages')
6162

6263
assert isinstance(message, ConversationMessage)
@@ -85,9 +86,11 @@ def test_get_conversation_ok(get_mock):
8586
call(
8687
headers={'Content-Type': 'application/json', 'Authorization': 'ApiKey XXXX:YYYYY'},
8788
params={'instance_id': request.id},
89+
timeout=300,
8890
url='http://localhost:8080/api/public/v1/conversations'),
8991
call(
9092
headers={'Content-Type': 'application/json', 'Authorization': 'ApiKey XXXX:YYYYY'},
93+
timeout=300,
9194
url='http://localhost:8080/api/public/v1/conversations/' + conversation.id)
9295
])
9396

@@ -107,6 +110,7 @@ def test_get_conversation_empty(get_mock):
107110
call(
108111
headers={'Content-Type': 'application/json', 'Authorization': 'ApiKey XXXX:YYYYY'},
109112
params={'instance_id': request.id},
113+
timeout=300,
110114
url='http://localhost:8080/api/public/v1/conversations')
111115
])
112116

@@ -129,9 +133,11 @@ def test_get_conversation_bad_deserialize(get_mock):
129133
call(
130134
headers={'Content-Type': 'application/json', 'Authorization': 'ApiKey XXXX:YYYYY'},
131135
params={'instance_id': request.id},
136+
timeout=300,
132137
url='http://localhost:8080/api/public/v1/conversations'),
133138
call(
134139
headers={'Content-Type': 'application/json', 'Authorization': 'ApiKey XXXX:YYYYY'},
140+
timeout=300,
135141
url='http://localhost:8080/api/public/v1/conversations/CO-750-033-356')
136142
])
137143

tests/test_directory.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ def test_list_assets(get_mock):
6464
get_mock.assert_called_with(
6565
url='http://localhost:8080/api/public/v1/assets?in(product.id,(CN-631-322-000))',
6666
headers={'Content-Type': 'application/json', 'Authorization': 'ApiKey XXXX:YYYYY'},
67+
timeout=300,
6768
params=None)
6869

6970

@@ -76,7 +77,8 @@ def test_get_asset(get_mock):
7677

7778
get_mock.assert_called_with(
7879
url='http://localhost:8080/api/public/v1/assets/AS-9861-7949-8492',
79-
headers={'Content-Type': 'application/json', 'Authorization': 'ApiKey XXXX:YYYYY'})
80+
headers={'Content-Type': 'application/json', 'Authorization': 'ApiKey XXXX:YYYYY'},
81+
timeout=300)
8082

8183

8284
@patch('requests.get', MagicMock(return_value=_get_bad_response()))
@@ -96,7 +98,8 @@ def test_list_products(get_mock):
9698

9799
get_mock.assert_called_with(
98100
url='http://localhost:8080/api/public/v1/products',
99-
headers={'Content-Type': 'application/json', 'Authorization': 'ApiKey XXXX:YYYYY'})
101+
headers={'Content-Type': 'application/json', 'Authorization': 'ApiKey XXXX:YYYYY'},
102+
timeout=300)
100103

101104

102105
@patch('requests.get')
@@ -108,7 +111,8 @@ def test_get_product(get_mock):
108111

109112
get_mock.assert_called_with(
110113
url='http://localhost:8080/api/public/v1/products/CN-783-317-575',
111-
headers={'Content-Type': 'application/json', 'Authorization': 'ApiKey XXXX:YYYYY'})
114+
headers={'Content-Type': 'application/json', 'Authorization': 'ApiKey XXXX:YYYYY'},
115+
timeout=300)
112116

113117

114118
@patch('requests.get', MagicMock(return_value=_get_bad_response()))
@@ -129,6 +133,7 @@ def test_list_tier_configs(get_mock):
129133
get_mock.assert_called_with(
130134
url='http://localhost:8080/api/public/v1/tier/configs',
131135
headers={'Content-Type': 'application/json', 'Authorization': 'ApiKey XXXX:YYYYY'},
136+
timeout=300,
132137
params={'product.id': 'CN-631-322-000'})
133138

134139

@@ -141,7 +146,8 @@ def test_get_tier_config(get_mock):
141146

142147
get_mock.assert_called_with(
143148
url='http://localhost:8080/api/public/v1/tier/configs/TC-000-000-000',
144-
headers={'Content-Type': 'application/json', 'Authorization': 'ApiKey XXXX:YYYYY'})
149+
headers={'Content-Type': 'application/json', 'Authorization': 'ApiKey XXXX:YYYYY'},
150+
timeout=300)
145151

146152

147153
@patch('requests.get', MagicMock(return_value=_get_bad_response()))

tests/test_models.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@ def test_get_tier_config(get_mock):
221221
headers={
222222
'Content-Type': 'application/json',
223223
'Authorization': 'ApiKey XXXX:YYYYY'},
224+
timeout=300,
224225
params={
225226
'status': 'approved',
226227
'configuration__product__id': 'product_id',

tests/test_usage.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ def test_get_usage_template_ok(get_mock):
5454
get_mock.assert_has_calls([
5555
call(
5656
url='http://localhost:8080/api/public/v1/usage/products/PRD-638-321-603/template/',
57-
headers={'Content-Type': 'application/json', 'Authorization': 'ApiKey XXXX:YYYYY'}),
57+
headers={'Content-Type': 'application/json', 'Authorization': 'ApiKey XXXX:YYYYY'},
58+
timeout=300),
5859
call('...')
5960
])
6061

0 commit comments

Comments
 (0)