Ejemplo n.º 1
0
    def test_gen_buttons_big(self):
        buttons = gen_buttons([('a', 5), ('b', 20000)], blank=False)
        buttons = [(b.text, b.callback_data) for b in buttons]
        assert buttons == [('a 5', 'button:a'), ('b 20k', 'button:b')]

        buttons = gen_buttons([('a', 5), ('b', 20100)], blank=False)
        buttons = [(b.text, b.callback_data) for b in buttons]
        assert buttons == [('a 5', 'button:a'), ('b 20.1k', 'button:b')]
Ejemplo n.º 2
0
 def test_fluid_merge_keyboards(self):
     bs1 = gen_buttons([('a', 0), ('b', 0)])
     bs2 = gen_buttons([('с', 0), ('d', 0)])
     kb = fluid_merge_keyboards(
         InlineKeyboardMarkup([bs1]),
         None,
         InlineKeyboardMarkup([bs2]),
         max_cols=5,
     ).inline_keyboard
     assert len(kb) == 1
     assert len(kb[0]) == 4
Ejemplo n.º 3
0
 def test_fluid_merge_keyboards_padding(self):
     bs1 = gen_buttons([('a', 0), ('b', 0)])
     bs2 = gen_buttons([('с', 0), ('d', 0)])
     kb = fluid_merge_keyboards(InlineKeyboardMarkup([bs1]),
                                None,
                                InlineKeyboardMarkup([bs2]),
                                InlineKeyboardMarkup([bs1]),
                                InlineKeyboardMarkup([bs2]),
                                max_cols=5,
                                padding=True).inline_keyboard
     assert len(kb) == 2
     assert len(kb[0]) == 5
     assert len(kb[1]) == 5
     assert kb[1][-1].callback_data == EMPTY_CB_DATA
Ejemplo n.º 4
0
 def test_gen_buttons_blank(self):
     buttons = gen_buttons(['a', ('b', 2)], blank=True)
     buttons = [(b.text, b.callback_data) for b in buttons]
     assert buttons == [('a', EMPTY_CB_DATA), ('b 2', EMPTY_CB_DATA)]
Ejemplo n.º 5
0
 def test_gen_buttons(self):
     buttons = gen_buttons(['a', ('b', 2)], blank=False)
     buttons = [(b.text, b.callback_data) for b in buttons]
     assert buttons == [('a', 'button:a'), ('b 2', 'button:b')]