Пример #1
0
def test_dao_get_paginated_inbound_sms_for_service_for_public_api(
        sample_service):
    inbound_sms = create_inbound_sms(service=sample_service)
    inbound_from_db = dao_get_paginated_inbound_sms_for_service_for_public_api(
        inbound_sms.service.id)

    assert inbound_sms == inbound_from_db[0]
Пример #2
0
def test_dao_get_paginated_inbound_sms_for_service_for_public_api_return_only_for_service(sample_service):
    inbound_sms = create_inbound_sms(service=sample_service)
    another_service = create_service(service_name='another service')
    another_inbound_sms = create_inbound_sms(another_service)

    inbound_from_db = dao_get_paginated_inbound_sms_for_service_for_public_api(inbound_sms.service.id)

    assert inbound_sms in inbound_from_db
    assert another_inbound_sms not in inbound_from_db
Пример #3
0
def get_inbound_sms():
    data = validate(request.args.to_dict(), get_inbound_sms_request)

    paginated_inbound_sms = inbound_sms_dao.dao_get_paginated_inbound_sms_for_service_for_public_api(
        authenticated_service.id,
        older_than=data.get('older_than', None),
        page_size=current_app.config.get('API_PAGE_SIZE'))

    return jsonify(
        received_text_messages=[i.serialize() for i in paginated_inbound_sms],
        links=_build_links(paginated_inbound_sms)), 200
Пример #4
0
def test_dao_get_paginated_inbound_sms_for_service_for_public_api_older_than_end_returns_empty_list(
        sample_service):
    inbound_sms_list = [
        create_inbound_sms(sample_service),
        create_inbound_sms(sample_service),
    ]
    reversed_inbound_sms = sorted(inbound_sms_list,
                                  key=lambda sms: sms.created_at,
                                  reverse=True)

    inbound_from_db = dao_get_paginated_inbound_sms_for_service_for_public_api(
        sample_service.id, older_than=reversed_inbound_sms[1].id, page_size=2)

    assert inbound_from_db == []
Пример #5
0
def test_dao_get_paginated_inbound_sms_for_service_for_public_api_no_inbound_sms_returns_empty_list(
        sample_service):
    inbound_from_db = dao_get_paginated_inbound_sms_for_service_for_public_api(
        sample_service.id)

    assert inbound_from_db == []