def test_choices_choose_default(self): """Choices with a default without any answer return callback""" callback1 = Mock() choices = [Choice(0, "Choice0", Mock()), Choice(1, "Choice1", callback1, is_default=True), Choice(2, "Choice2", Mock())] inter = TextWithChoices("Foo Content", choices) self.assertEquals(inter.choose(), callback1.return_value)
def test_choices_choose_with_label_no_right_casse(self): """Choose with label without respecting the casse""" callback1 = Mock() choices = [Choice(0, "Choice0", Mock()), Choice(1, "Choice1", callback1), Choice(2, "Choice2", Mock())] inter = TextWithChoices("Foo Content", choices) self.assertEquals(inter.choose(answer='chOIce1'), callback1.return_value)
def test_choices_choose_with_shorcut_no_right_casse(self): """Choose with shortcut without respecting the casse""" callback1 = Mock() choices = [Choice(0, "Choice0", Mock(), txt_shorcut="A"), Choice(1, "Choice1", callback1, txt_shorcut="B"), Choice(2, "Choice2", Mock())] inter = TextWithChoices("Foo Content", choices) self.assertEquals(inter.choose(answer='b'), callback1.return_value)
def test_choices_choose_with_partial_shorcut_run_right_callback(self): """Choose with some having text shortcut calls the correct callback""" callback1 = Mock() choices = [Choice(0, "Choice0", Mock()), Choice(1, "Choice1", callback1, txt_shorcut="B"), Choice(2, "Choice2", Mock())] inter = TextWithChoices("Foo Content", choices) self.assertEquals(inter.choose(answer='B'), callback1.return_value)
def test_choices_choose_run_right_callback(self): """Choose call the correct callback""" callback1 = Mock() callback2 = Mock() choices = [Choice(0, "Choice0", Mock()), Choice(1, "Choice1", callback1), Choice(2, "Choice2", callback2)] inter = TextWithChoices("Foo Content", choices) self.assertEquals(inter.choose(choice_id=1), callback1.return_value) self.assertEquals(inter.choose(choice_id=2), callback2.return_value)
def test_choices_choose_with_label_run_right_callback(self): """Choose with label calls the correct callback""" callback1 = Mock() callback2 = Mock() choices = [Choice(0, "Choice0", Mock(), txt_shorcut="A"), Choice(1, "Choice1", callback1, txt_shorcut="B"), Choice(2, "Choice2", callback2, txt_shorcut="C")] inter = TextWithChoices("Foo Content", choices) self.assertEquals(inter.choose(answer='Choice1'), callback1.return_value) self.assertEquals(inter.choose(answer='Choice2'), callback2.return_value)