Exemplo n.º 1
0
def test_get_status_from_internal_message(requester):
    requester.message = api.SMSMessage(body='test message text')
    response = requester.send(recipients=api.Recipient(380967770002))
    assert response.get('result')
    assert response['result'].get('id')
    response['status'] = requester.get_status()
    assert response.get('status') is not None and response.get('status')
Exemplo n.º 2
0
def test_message():
    message = api.SMSMessage(body='test message text')

    assert len(message) == 2

    attributes = ['body', 'originator']
    for attribute in attributes:
        assert message.get(attribute) is not None
Exemplo n.º 3
0
def test_get_status_by_task_id(requester):
    requester.message = api.SMSMessage(body='test message text')
    requester.clear_recipients()
    requester.add_recipient(api.Recipient(380967770004))
    requester.add_recipient(api.Recipient(380967770005))
    response_send = requester.send()
    assert response_send
    response_status = requester.get_status()
    assert requester.message.get('status') is not None and response_status
Exemplo n.º 4
0
def main():
    from examples.settings import API_KEY

    try:
        client = api.SMSAPI(config={'api_key': API_KEY})
        prices = client.get_prices()
        print('SMS Prices (first 5 elements from {}): \n{}'.format(
            len(prices), pprint.pformat(prices[0:5], indent=4)))

        recipient = api.Recipient(380967000000)
        print('Created recipient: \n{}'.format(pprint.pformat(recipient)))
        result = client.send(message=api.SMSMessage('hello from bsg.world'),
                             recipients=recipient)
        print('Current SMS send API result: \n{}'.format(
            pprint.pformat(result, indent=4)))
        status = client.get_status(result['result']['reference'])
        print('Current SMS status result: \n{}\n'.format(
            pprint.pformat(status, indent=4)))

        recipient0 = api.Recipient(380967000001)
        recipient1 = api.Recipient(380967000002)
        print('Created another one recipients: \n{}'.format(
            pprint.pformat([recipient0, recipient1])))
        results = client.send(message=api.SMSMessage('hello from bsg.world'),
                              recipients=[recipient0, recipient1])
        for result in results['result']:
            print('Current SMS send API result for reference {}: \n{}'.format(
                result['reference'], pprint.pformat(result, indent=4)))
            status = client.get_status(result['reference'])
            print('Current SMS status result for reference {}: \n{}'.format(
                result['reference'], pprint.pformat(status, indent=4)))
    except api.APIError as exc:
        print('Error on SMS request processing: {}'.format(
            pprint.pformat(exc, indent=4)),
              file=sys.stderr)
        exit(1)
Exemplo n.º 5
0
def test_get_status_from_internal_message_without_send(requester):
    requester.message = api.SMSMessage(body='test message text')
    requester.clear_recipients()
    requester.add_recipient(api.Recipient(380967770003))
    response = requester.get_status()
    assert requester.message.get('status') is not None and response
Exemplo n.º 6
0
def test_get_status_one(requester):
    response = requester.send(message=api.SMSMessage(body='test message text'), recipients=api.Recipient(380967770002))
    assert response.get('result')
    assert response['result'].get('id') is not None
    response['status'] = requester.get_status(response['result']['id'])
    assert response.get('status') is not None
Exemplo n.º 7
0
def test_send_mul(requester):
    responds = requester.send(message=api.SMSMessage(body='test message text'), recipients=[api.Recipient(380967770000), api.Recipient(380967770001)])
    assert responds.get('result')
    for respond in responds['result']:
        for attribute in RESPOND_ATTRIBUTES:
            assert respond.get(attribute) is not None
Exemplo n.º 8
0
def test_send_one(requester):
    respond = requester.send(message=api.SMSMessage(body='test message text'), recipients=api.Recipient(380967770002))
    assert respond.get('result')
    for attribute in RESPOND_ATTRIBUTES:
        assert respond['result'].get(attribute) is not None