def test_ReplyKeyboardMarkup_2cols(self): rkm = ReplyMarkups.ReplyKeyboardMarkup(resize_keyboard=True) rkm.add_button(Buttons.KeyboardButton('Text1', request_location=True), row=1, col=1) rkm.add_button(Buttons.KeyboardButton('Text2', True), row=2, col=1) self.assertEqual(str(rkm.get_markup()), "{'resize_keyboard': True, 'keyboard': [[{'text': 'Text1', " + "'request_location': True}], [{'text': 'Text2', " + "'request_contact': True}]]}")
def test_ReplyKeyboardMarkup_get_button(self): rkm = ReplyMarkups.ReplyKeyboardMarkup() rkm.add_button(Buttons.KeyboardButton('Text 1'), col=1, row=1) rkm.add_button(Buttons.KeyboardButton('Text 1'), col=1, row=2) button = rkm.get_button(col=1, row=2) self.assertEqual(button.get_markup(), {'text': 'Text 1'}) self.assertEqual(rkm.get_markup(), {'resize_keyboard': True, 'keyboard': [[{'text': 'Text 1'}], [{'text': 'Text 1'}]]})
def test_kb_create_with_text(self): kb = Buttons.KeyboardButton('name') self.assertEqual(kb.get_text(), 'name') self.assertEqual(kb.is_request_contact(), False) self.assertEqual(kb.is_request_location(), False)
def test_ReplyKeyboardMarkup_twice_the_same_place(self): with self.assertRaises(Exception): rkm = ReplyMarkups.ReplyKeyboardMarkup() rkm.add_button(Buttons.KeyboardButton('Text 1'), col=1, row=1) rkm.add_button(Buttons.KeyboardButton('Text 1'), col=1, row=1)
def test_kb_create_with_incorrect_request_location(self): with self.assertRaises(AssertionError): Buttons.KeyboardButton('name', request_location=1.0)
def test_kb_create_with_incorrect_name(self): with self.assertRaises(AssertionError): Buttons.KeyboardButton(1)