173 |
173 |
assert test_vector['result']['err_desc'] in job.status_details['error_summary']
|
174 |
174 |
nb_failed += 1
|
175 |
175 |
else:
|
176 |
176 |
assert job.status == 'completed'
|
177 |
177 |
assert Job.objects.filter(method_name='send_job').count() == total
|
178 |
178 |
assert SMSLog.objects.count() == total - nb_failed
|
179 |
179 |
|
180 |
180 |
|
|
181 |
@pytest.mark.parametrize('connector', [OVHSMSGateway], indirect=True)
|
|
182 |
def test_sms_legacy_retry_after_error(app, connector, freezer):
|
|
183 |
path = '/%s/%s/send/' % (connector.get_connector_slug(), connector.slug)
|
|
184 |
assert not SMSLog.objects.filter(appname=connector.get_connector_slug(), slug=connector.slug).exists()
|
|
185 |
|
|
186 |
payload = {
|
|
187 |
'message': 'plop',
|
|
188 |
'from': '+33699999999',
|
|
189 |
'to': ['+33688888888'],
|
|
190 |
}
|
|
191 |
freezer.move_to('2019-01-01 00:00:00')
|
|
192 |
result = app.post_json(path, params=payload)
|
|
193 |
assert result.json['err'] == 0
|
|
194 |
assert Job.objects.exists()
|
|
195 |
assert Job.objects.get().status == 'registered'
|
|
196 |
assert not Job.objects.get().after_timestamp
|
|
197 |
with utils.mock_url(
|
|
198 |
url=connector.URL,
|
|
199 |
response={'status': 429, 'message': 'Too much requests.\nPlease retry in 3 seconds.'},
|
|
200 |
):
|
|
201 |
connector.jobs()
|
|
202 |
assert Job.objects.get().status == 'registered'
|
|
203 |
assert Job.objects.get().after_timestamp
|
|
204 |
|
|
205 |
with utils.mock_url(url=connector.URL, response={'status': 100, 'credit_left': 22}):
|
|
206 |
connector.jobs()
|
|
207 |
assert Job.objects.get().status == 'registered'
|
|
208 |
|
|
209 |
freezer.move_to('2019-01-01 00:00:04')
|
|
210 |
with utils.mock_url(url=connector.URL, response={'status': 100, 'creditLeft': 22}):
|
|
211 |
connector.jobs()
|
|
212 |
assert Job.objects.get().status == 'completed'
|
|
213 |
assert SMSLog.objects.exists()
|
|
214 |
|
|
215 |
|
181 |
216 |
def test_manage_views(admin_user, app, connector):
|
182 |
217 |
url = '/%s/%s/' % (connector.get_connector_slug(), connector.slug)
|
183 |
218 |
resp = app.get(url)
|
184 |
219 |
assert 'Endpoints' in resp.text
|
185 |
220 |
assert not 'accessright/add' in resp.text
|
186 |
221 |
app = login(app)
|
187 |
222 |
resp = app.get(url)
|
188 |
223 |
description_fields = [
|
189 |
|
-
|