예제 #1
0
    def test_de_json(self, bot, emoji):
        json_dict = {'value': self.value, 'emoji': emoji}
        dice = Dice.de_json(json_dict, bot)

        assert dice.value == self.value
        assert dice.emoji == emoji
        assert Dice.de_json(None, bot) is None
예제 #2
0
    def test_filters_dice_type(self, update):
        update.message.dice = Dice(5, '🎲')
        assert Filters.dice.dice(update)
        assert Filters.dice.dice([4, 5])(update)
        assert not Filters.dice.darts(update)
        assert not Filters.dice.dice([6])(update)

        update.message.dice = Dice(5, '🎯')
        assert Filters.dice.darts(update)
        assert Filters.dice.darts([4, 5])(update)
        assert not Filters.dice.dice(update)
        assert not Filters.dice.darts([6])(update)
    def test_equality(self):
        a = Dice(3, "🎯")
        b = Dice(3, "🎯")
        c = Dice(3, "🎲")
        d = Dice(4, "🎯")
        e = BotCommand("start", "description")

        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)
예제 #4
0
    def test_filters_dice_iterable(self, update):
        update.message.dice = None
        assert not Filters.dice(5)(update)

        update.message.dice = Dice(5)
        assert Filters.dice(5)(update)
        assert Filters.dice({5, 6})(update)
        assert not Filters.dice(1)(update)
        assert not Filters.dice([2, 3])(update)
예제 #5
0
    def test_equality(self):
        a = Dice(3, '🎯')
        b = Dice(3, '🎯')
        c = Dice(3, '🎲')
        d = Dice(4, '🎯')
        e = BotCommand('start', 'description')

        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)
예제 #6
0
    def test_filters_dice_list(self, update, emoji):
        update.message.dice = None
        assert not Filters.dice(5)(update)

        update.message.dice = Dice(5, emoji)
        assert Filters.dice(5)(update)
        assert Filters.dice({5, 6})(update)
        assert not Filters.dice(1)(update)
        assert not Filters.dice([2, 3])(update)
예제 #7
0
    def test_filters_dice_type(self, update):
        update.message.dice = Dice(5, '🎲')
        assert Filters.dice.dice(update)
        assert Filters.dice.dice([4, 5])(update)
        assert not Filters.dice.darts(update)
        assert not Filters.dice.basketball(update)
        assert not Filters.dice.dice([6])(update)

        update.message.dice = Dice(5, '🎯')
        assert Filters.dice.darts(update)
        assert Filters.dice.darts([4, 5])(update)
        assert not Filters.dice.dice(update)
        assert not Filters.dice.basketball(update)
        assert not Filters.dice.darts([6])(update)

        update.message.dice = Dice(5, '🏀')
        assert Filters.dice.basketball(update)
        assert Filters.dice.basketball([4, 5])(update)
        assert not Filters.dice.dice(update)
        assert not Filters.dice.darts(update)
        assert not Filters.dice.basketball([4])(update)
예제 #8
0
    def test_equality(self):
        a = BotCommand('start', 'some description')
        b = BotCommand('start', 'some description')
        c = BotCommand('start', 'some other description')
        d = BotCommand('hepl', 'some description')
        e = Dice(4, 'emoji')

        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)
예제 #9
0
    def test_equality(self):
        a = BotCommand("start", "some description")
        b = BotCommand("start", "some description")
        c = BotCommand("start", "some other description")
        d = BotCommand("hepl", "some description")
        e = Dice(4, "emoji")

        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)
예제 #10
0
    def test_equality(self, menu_button, bot):
        a = MenuButton("base_type")
        b = MenuButton("base_type")
        c = menu_button
        d = deepcopy(menu_button)
        e = Dice(4, "emoji")

        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)

        assert c == d
        assert hash(c) == hash(d)

        assert c != e
        assert hash(c) != hash(e)

        if hasattr(c, "web_app"):
            json_dict = c.to_dict()
            json_dict["web_app"] = WebAppInfo(
                "https://foo.bar/web_app").to_dict()
            f = c.__class__.de_json(json_dict, bot)

            assert c != f
            assert hash(c) != hash(f)

        if hasattr(c, "text"):
            json_dict = c.to_dict()
            json_dict["text"] = "other text"
            g = c.__class__.de_json(json_dict, bot)

            assert c != g
            assert hash(c) != hash(g)
    def test_equality(self, bot_command_scope, bot):
        a = BotCommandScope('base_type')
        b = BotCommandScope('base_type')
        c = bot_command_scope
        d = deepcopy(bot_command_scope)
        e = Dice(4, 'emoji')

        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)

        assert c == d
        assert hash(c) == hash(d)

        assert c != e
        assert hash(c) != hash(e)

        if hasattr(c, 'chat_id'):
            json_dict = c.to_dict()
            json_dict['chat_id'] = 0
            f = c.__class__.de_json(json_dict, bot)

            assert c != f
            assert hash(c) != hash(f)

        if hasattr(c, 'user_id'):
            json_dict = c.to_dict()
            json_dict['user_id'] = 0
            g = c.__class__.de_json(json_dict, bot)

            assert c != g
            assert hash(c) != hash(g)
    def test_equality(self, chat_member_type):
        a = ChatMember(status="status", user=CMDefaults.user)
        b = ChatMember(status="status", user=CMDefaults.user)
        c = chat_member_type
        d = deepcopy(chat_member_type)
        e = Dice(4, "emoji")

        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)

        assert c == d
        assert hash(c) == hash(d)

        assert c != e
        assert hash(c) != hash(e)
    def test_equality(self, chat_member_types, user):
        a = ChatMember(status='status', user=user)
        b = ChatMember(status='status', user=user)
        c = chat_member_types
        d = deepcopy(chat_member_types)
        e = Dice(4, 'emoji')

        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)

        assert c == d
        assert hash(c) == hash(d)

        assert c != e
        assert hash(c) != hash(e)
예제 #14
0
                         'text': 'next',
                         'callback_data': 'abcd'
                     },
                 ],
                 [{
                     'text': 'Cancel',
                     'callback_data': 'Cancel'
                 }],
             ]
         },
     },
     {
         'quote': True
     },
     {
         'dice': Dice(4, '🎲')
     },
     {
         'via_bot': User(9, 'A_Bot', True)
     },
     {
         'proximity_alert_triggered':
         ProximityAlertTriggered(User(1, 'John', False),
                                 User(2, 'Doe', False), 42)
     },
     {
         'sender_chat': Chat(-123, 'discussion_channel')
     },
 ],
 ids=[
     'forwarded_user',
예제 #15
0
파일: test_dice.py 프로젝트: Crackde/iptv
def dice():
    return Dice(value=5)
예제 #16
0
파일: test_dice.py 프로젝트: Crackde/iptv
    def test_de_json(self, bot):
        json_dict = {'value': self.value}
        dice = Dice.de_json(json_dict, bot)

        assert dice.value == self.value
        assert Dice.de_json(None, bot) is None
예제 #17
0
def dice(request):
    return Dice(value=5, emoji=request.param)
예제 #18
0
 def test_filters_dice(self, update, emoji):
     update.message.dice = Dice(4, emoji)
     assert Filters.dice(update)
     update.message.dice = None
     assert not Filters.dice(update)
예제 #19
0
        'reply_markup': {
            'inline_keyboard': [[{
                'text': 'start',
                'url': 'http://google.com'
            }, {
                'text': 'next',
                'callback_data': 'abcd'
            }], [{
                'text': 'Cancel',
                'callback_data': 'Cancel'
            }]]
        }
    }, {
        'quote': True
    }, {
        'dice': Dice(4)
    }],
    ids=[
        'forwarded_user', 'forwarded_channel', 'reply', 'edited', 'text',
        'caption_entities', 'audio', 'document', 'animation', 'game', 'photo',
        'sticker', 'video', 'voice', 'video_note', 'new_members', 'contact',
        'location', 'venue', 'left_member', 'new_title', 'new_photo',
        'delete_photo', 'group_created', 'supergroup_created',
        'channel_created', 'migrated_to', 'migrated_from', 'pinned', 'invoice',
        'successful_payment', 'connected_website', 'forward_signature',
        'author_signature', 'photo_from_media_group', 'passport_data', 'poll',
        'reply_markup', 'default_quote', 'dice'
    ])
def message_params(bot, request):
    return Message(message_id=TestMessage.id_,
                   from_user=TestMessage.from_user,