Exemplo n.º 1
0
    def test_max_recursion(self):
        client = MockClient("clientid")
        bot_config = MockBotConfiguration(1, 1)
        bot = MockBot("botid", bot_config)
        brain = MockBrain("brainid")
        context = ClientContext(client, "testid")
        context.bot = bot
        context.brain = brain
        self.assertEquals("[clientid] [testid] [botid] [brainid] [0]",
                          str(context))

        context.mark_question_start("question1")

        context.check_max_recursion()

        context.mark_question_start("question2")

        with self.assertRaises(Exception):
            context.check_max_recursion()
Exemplo n.º 2
0
    def test_question(self):
        client = MockClient("clientid")
        bot = MockBot("botid", None)
        brain = MockBrain("brainid")
        context = ClientContext(client, "testid")
        context.bot = bot
        context.brain = brain
        self.assertEquals("[clientid] [testid] [botid] [brainid] [0]",
                          str(context))

        context.mark_question_start("question")

        self.assertEquals("[clientid] [testid] [botid] [brainid] [1]",
                          str(context))

        context.mark_question_start("question")

        self.assertEquals("[clientid] [testid] [botid] [brainid] [2]",
                          str(context))

        context.reset_question()

        self.assertEquals("[clientid] [testid] [botid] [brainid] [0]",
                          str(context))