# Path: src/schemas/messages.py
# class MessageStatus(str, Enum):
#     """
#     Combined MandrillMessageStatus and MessageBirdMessageStatus
# 
#     Should match MESSAGE_STATUSES sql enum
#     """
# 
#     render_failed = 'render_failed'
#     send_request_failed = 'send_request_failed'
# 
#     send = 'send'
#     deferral = 'deferral'
#     hard_bounce = 'hard_bounce'
#     soft_bounce = 'soft_bounce'
#     open = 'open'
#     click = 'click'
#     spam = 'spam'
#     unsub = 'unsub'
#     reject = 'reject'
# 
#     # used for sms
#     scheduled = 'scheduled'
#     # send = 'send'  # above
#     buffered = 'buffered'
#     delivered = 'delivered'
#     expired = 'expired'
#     delivery_failed = 'delivery_failed'


import hashlib
import hmac
import json
import uuid
from buildpg import V, Values
from datetime import date, datetime, timedelta, timezone
from foxglove import glove
from foxglove.db.helpers import SyncDb
from operator import itemgetter
from pytest_toolbox.comparison import RegexStr
from starlette.testclient import TestClient
from urllib.parse import urlencode
from src.schemas.messages import MessageStatus
        'insert into events (:values__names) values :values',
        [
            Values(
                ts=(datetime(2032, 6, 1) + timedelta(days=i, hours=i * 2)).replace(tzinfo=timezone.utc),
                message_id=message_id,
                status=MessageStatus.send,
                extra=json.dumps({'foo': 'bar', 'v': i}),
            )
            for i in range(55)
        ],
    )

    r = cli.get(modify_url(f'/messages/email-test/{message_id}/', settings, 'test-details'))
    assert r.status_code == 200, r.text
    events = r.json()['events']
    assert len(events) == 51
    assert sync_db.fetchval('select count(*) from events') == 55
    assert events[-1]['status'] == '5 more'


def test_user_sms_list(cli, settings, send_sms, sync_db: SyncDb):
    ext_id = send_sms(company_code='snapcrap')

    send_sms(uid=str(uuid.uuid4()), company_code='flip')
    r = cli.get(modify_url('/messages/sms-test/', settings, 'snapcrap'))
    assert r.status_code == 200, r.text
    data = r.json()
    assert data == {
        'items': [
            {

# Path: src/schemas/messages.py
# class MessageStatus(str, Enum):
#     """
#     Combined MandrillMessageStatus and MessageBirdMessageStatus
# 
#     Should match MESSAGE_STATUSES sql enum
#     """
# 
#     render_failed = 'render_failed'
#     send_request_failed = 'send_request_failed'
# 
#     send = 'send'
#     deferral = 'deferral'
#     hard_bounce = 'hard_bounce'
#     soft_bounce = 'soft_bounce'
#     open = 'open'
#     click = 'click'
#     spam = 'spam'
#     unsub = 'unsub'
#     reject = 'reject'
# 
#     # used for sms
#     scheduled = 'scheduled'
#     # send = 'send'  # above
#     buffered = 'buffered'
#     delivered = 'delivered'
#     expired = 'expired'
#     delivery_failed = 'delivery_failed'


# Path: tests/test_user_display.py
import hashlib
import hmac
import json
import uuid
from buildpg import V, Values
from datetime import date, datetime, timedelta, timezone
from foxglove import glove
from foxglove.db.helpers import SyncDb
from operator import itemgetter
from pytest_toolbox.comparison import RegexStr
from starlette.testclient import TestClient
from urllib.parse import urlencode
from src.schemas.messages import MessageStatus

        'insert into events (:values__names) values :values',
        [
            Values(
                ts=(datetime(2032, 6, 1) + timedelta(days=i, hours=i * 2)).replace(tzinfo=timezone.utc),
                message_id=message_id,
                status=MessageStatus.send,
                extra=json.dumps({'foo': 'bar', 'v': i}),
            )
            for i in range(55)
        ],
    )

    r = cli.get(modify_url(f'/messages/email-test/{message_id}/', settings, 'test-details'))
    assert r.status_code == 200, r.text
    events = r.json()['events']
    assert len(events) == 51
    assert sync_db.fetchval('select count(*) from events') == 55
    assert events[-1]['status'] == '5 more'


def test_user_sms_list(cli, settings, send_sms, sync_db: SyncDb):
    ext_id = send_sms(company_code='snapcrap')

    send_sms(uid=str(uuid.uuid4()), company_code='flip')
    r = cli.get(modify_url('/messages/sms-test/', settings, 'snapcrap'))
    assert r.status_code == 200, r.text
    data = r.json()
    assert data == {
        'items': [
            {

                'id': 1,