コード例 #1
0
ファイル: event_test.py プロジェクト: samyak-jain/matrix-nio
    def test_ephemeral_event(self):
        event = EphemeralEvent.parse_event({})

        assert not event

        event = EphemeralEvent.parse_event({"type": "m.unknown", "content": {}})

        assert not event
コード例 #2
0
ファイル: event_test.py プロジェクト: samyak-jain/matrix-nio
    def test_typing_event(self):
        parsed_dict = TestClass._load_response("tests/data/events/typing.json")
        event = EphemeralEvent.parse_event(parsed_dict)

        assert isinstance(event, TypingNoticeEvent)

        assert "@bob:example.com" in event.users
コード例 #3
0
    def test_read_receipt_event(self):
        parsed_dict = TestClass._load_response(
            "tests/data/events/receipt.json")
        event = EphemeralEvent.parse_event(parsed_dict)

        # Warning: this is directly tied to the above file; any changes below
        # need to be reflected there too.
        receipt = Receipt("$152037280074GZeOm:localhost", "m.read",
                          "@bob:example.com", 1520372804619)

        assert isinstance(event, ReceiptEvent)
        assert receipt in event.receipts
コード例 #4
0
    def test_read_receipt_event_bad_ts(self):
        """Test reading an m_receipt event that has malformed data for one user.

        @alice:example.com is a user using Synapse pre 0.99.3 with a
        timestamp bug. We want to ignore her malformed value without losing
        the receipt data from @bob:example.com
        """
        parsed_dict = TestClass._load_response(
            "tests/data/events/receipt_invalid.json")
        event = EphemeralEvent.parse_event(parsed_dict)

        # Warning: this is directly tied to the above file; any changes below
        # need to be reflected there too.
        receipt = Receipt("$152037280074GZeOm:localhost", "m.read",
                          "@bob:example.com", 1520372804619)

        assert isinstance(event, ReceiptEvent)
        assert receipt in event.receipts