Пример #1
0
 def setUp(self):
     self.api = sms.SmsAPI(urls="https://test-sms-validate.example.com")
     self.correct_data = {
         "to": "+37212345678",
         "text": "test",
         "time_to_send": int(time.time()) + 60,
         "validity": 10,
         "autoconvert": "full",
         "udh": "MS",
         "mclass": 1,
         "text-store": "nostore",
     }
Пример #2
0
def test_send_no_validate():
    sms_id = "sms-001"
    text = "OK %s" % sms_id
    responses.add_callback(
        responses.GET,
        utils.TEST_ANY_URL,
        callback=utils.mock_response(200, text),
    )

    api = sms.SmsAPI(urls=utils.TEST_URL)
    api.send({}, validate=False)
    # OK if no exception was raised
    assert True
Пример #3
0
def test_invalid_credentials():
    responses.add_callback(
        responses.GET,
        utils.TEST_ANY_URL,
        callback=utils.mock_response(200, "ERROR 101"),
    )

    api = sms.SmsAPI(urls=utils.TEST_URL)
    r = api.send(mk_sms_data(), validate=False)
    assert isinstance(r, Response)
    assert isinstance(r, sms.SmsResponse)
    assert r.status == "ERROR"
    assert r.error_code == 101
    assert r.error_msg
Пример #4
0
def test_send():
    sms_id = "sms-001"
    text = "OK %s" % sms_id
    responses.add_callback(
        responses.GET,
        utils.TEST_ANY_URL,
        callback=utils.mock_response(200, text),
    )

    api = sms.SmsAPI(urls=utils.TEST_URL)
    r = api.send(mk_sms_data())

    assert r.error_code is None
    assert r.error_msg == ""
    assert r.status == "OK"
    assert r.get_raw_text() == text
    assert r.get_sms_id() == sms_id
Пример #5
0
def test_cancel():
    text = "OK DELETED"
    responses.add_callback(
        responses.GET,
        utils.TEST_ANY_URL,
        callback=utils.mock_response(200, text),
    )

    api = sms.SmsAPI(urls=utils.TEST_URL)
    r = api.cancel("sms-id")

    assert isinstance(r, Response)
    assert isinstance(r, sms.CancelSmsResponse)

    assert r.error_code is None
    assert r.error_msg == ""
    assert r.status == "OK"
    assert r.get_raw_text() == text
    assert r.get_result() == text