Exemple #1
0
    def test_to_dict(self, user1, user2):
        voice_chat_participants = VoiceChatParticipantsInvited([user1, user2])
        voice_chat_dict = voice_chat_participants.to_dict()

        assert isinstance(voice_chat_dict, dict)
        assert voice_chat_dict["users"] == [user1.to_dict(), user2.to_dict()]
        assert voice_chat_dict["users"][0]["id"] == user1.id
        assert voice_chat_dict["users"][1]["id"] == user2.id
Exemple #2
0
 def test_slot_behaviour(self, recwarn, mro_slots):
     action = VoiceChatParticipantsInvited([user1])
     for attr in action.__slots__:
         assert getattr(action, attr,
                        'err') != 'err', f"got extra slot '{attr}'"
     assert not action.__dict__, f"got missing slot(s): {action.__dict__}"
     assert len(mro_slots(action)) == len(set(
         mro_slots(action))), "duplicate slot"
     action.custom = 'should give warning'
     assert len(recwarn) == 1 and 'custom' in str(
         recwarn[0].message), recwarn.list
Exemple #3
0
    def test_equality(self, user1, user2):
        a = VoiceChatParticipantsInvited([user1])
        b = VoiceChatParticipantsInvited([user1])
        c = VoiceChatParticipantsInvited([user1, user2])
        d = VoiceChatParticipantsInvited([user2])
        e = VoiceChatStarted()

        assert a == b
        assert hash(a) == hash(b)

        assert a != c
        assert hash(a) != hash(c)

        assert a != d
        assert hash(a) != hash(d)

        assert a != e
        assert hash(a) != hash(e)
Exemple #4
0
    def test_de_json(self, user1, user2, bot):
        json_data = {"users": [user1.to_dict(), user2.to_dict()]}
        voice_chat_participants = VoiceChatParticipantsInvited.de_json(json_data, bot)

        assert isinstance(voice_chat_participants.users, list)
        assert voice_chat_participants.users[0] == user1
        assert voice_chat_participants.users[1] == user2
        assert voice_chat_participants.users[0].id == user1.id
        assert voice_chat_participants.users[1].id == user2.id