Ejemplo n.º 1
0
def test_send_sms_get_timeout():
    app = TindevQA()
    user = '******'
    text = 'Quieres enredarte entre mis pelos?'
    when(requests).post(...).thenRaise(Timeout)

    response = app.send_sms(user, text)
    assert response == "ERROR"
Ejemplo n.º 2
0
def test_send_sms_with_mockito():
    app = TindevQA()
    user = '******'
    text = 'Quieres enredarte entre mis pelos?'
    response_mock = mock({'status_code': 200, 'text': 'Ok'})
    when(requests).post(...).thenReturn(response_mock)

    response = app.send_sms(user, text)
    assert response.status_code == 200
Ejemplo n.º 3
0
def test_send_sms_get_500_error():
    app = TindevQA()
    user = '******'
    text = 'Quieres enredarte entre mis pelos?'
    response_mock = mock({'status_code': 501})
    when(requests).post(...).thenReturn(response_mock)

    response = app.send_sms(user, text)
    assert response.status_code == 501
Ejemplo n.º 4
0
def test_send_sms_with_error():
    app = TindevQA()
    user = '******'
    text = 'Quieres enredarte entre mis pelos?'
    data = {'status_code': 500, 'message': 'Servidor Caido'}

    r = requests.post('http://localhost:8080/set_response', json=data)

    response = app.send_sms(user, text)
    assert response.status_code == 500
    assert response.text == 'Servidor Caido'
Ejemplo n.º 5
0
def test_send_sms():

    app = TindevQA()
    user = '******'
    text = 'Quieres enredarte entre mis pelos?'
    response = app.send_sms(user, text)

    r = requests.get('http://localhost:8080/stats')
    body = r.json()

    assert body['requests'][0]['from'] == 'Chewaka'
    assert body['requests'][0]['to'] == '34677722314'
    assert body['requests'][0]['text'] == 'Quieres enredarte entre mis pelos?'
Ejemplo n.º 6
0
def test_send_sms():
    app = TindevQA()
    user = '******'
    text = 'Quieres enredarte entre mis pelos?'
    response = app.send_sms(user, text)
    assert response.ok == True