Exemple #1
0
def test_t_ms_full(session):
    """A full example of parsing of data in /t_ms."""
    payload = {
        "deltas": [{
            "deltaMessageReaction": {
                "threadKey": {
                    "threadFbId": 4321
                },
                "messageId": "mid.$XYZ",
                "action": 0,
                "userId": 1234,
                "reaction": "😢",
                "senderId": 1234,
                "offlineThreadingId": "1122334455",
            }
        }]
    }
    data = {
        "deltas": [
            {
                "payload": [ord(x) for x in _util.json_minimal(payload)],
                "class": "ClientPayload",
            },
            {
                "class": "NoOp",
            },
            {
                "forceInsert": False,
                "messageId": "mid.$ABC",
                "threadKey": {
                    "threadFbId": "4321"
                },
                "class": "ForcedFetch",
            },
        ],
        "firstDeltaSeqId":
        111111,
        "lastIssuedSeqId":
        111113,
        "queueEntityId":
        1234,
    }
    thread = Group(session=session, id="4321")
    assert [
        ReactionEvent(
            author=User(session=session, id="1234"),
            thread=thread,
            message=Message(thread=thread, id="mid.$XYZ"),
            reaction="😢",
        ),
        UnfetchedThreadEvent(
            thread=thread,
            message=Message(thread=thread, id="mid.$ABC"),
        ),
    ] == list(parse_events(session, "/t_ms", data))
def test_forced_fetch_pending(session):
    data = {
        "forceInsert": False,
        "irisSeqId": "1111",
        "isLazy": False,
        "threadKey": {"threadFbId": "1234"},
        "class": "ForcedFetch",
    }
    assert UnfetchedThreadEvent(
        thread=Group(session=session, id="1234"), message=None
    ) == parse_delta(session, data)
def test_forced_fetch(session):
    data = {
        "forceInsert": False,
        "messageId": "mid.$XYZ",
        "threadKey": {"threadFbId": "1234"},
        "class": "ForcedFetch",
    }
    thread = Group(session=session, id="1234")
    assert UnfetchedThreadEvent(
        thread=thread, message=Message(thread=thread, id="mid.$XYZ")
    ) == parse_delta(session, data)