Beispiel #1
0
    def test_bot_runs(self):

        session = otree.session.create_session(
            session_config_name='bots_raise',
            num_participants=2,
            use_cli_bots=True,
            bot_case_number=0,
        )

        bot_runner = session_bot_runner_factory(session)

        with self.assertRaises(ZeroDivisionError):
            bot_runner.play()
Beispiel #2
0
    def test_bot_runs(self):

        session = otree.session.create_session(
            session_config_name='bots',
            num_participants=2,
            use_cli_bots=True,
            bot_case_number=0,
        )

        bot_runner = session_bot_runner_factory(session)

        with self.assertRaises(ZeroDivisionError):
            bot_runner.play()
Beispiel #3
0
    def test_bot_bad_post(self):
        """
        Test that posting bad data without using SubmitInvalid
        will raise an error.
        """

        session = otree.session.create_session(
            session_config_name='bots_bad_post',
            num_participants=1,
            use_cli_bots=True,
            bot_case_number=0,
        )

        bot_runner = session_bot_runner_factory(session)

        with self.assertRaises(BotError):
            # need to disable log output, because this triggers an exception
            # that is logged to stdout
            logging.disable(logging.CRITICAL)
            bot_runner.play()
            logging.disable(logging.NOTSET)
Beispiel #4
0
    def test_bot_bad_post(self):
        """
        Test that posting bad data without using SubmitInvalid
        will raise an error.
        """

        session = otree.session.create_session(
            session_config_name='bots_bad_post',
            num_participants=1,
            use_cli_bots=True,
            bot_case_number=0,
        )

        bot_runner = session_bot_runner_factory(session)

        with self.assertRaises(AssertionError):
            # need to disable log output, because this triggers an exception
            # that is logged to stdout
            logging.disable(logging.CRITICAL)
            bot_runner.play()
            logging.disable(logging.NOTSET)
    def test_bots_check_html(self):

        session = otree.session.create_session(
            session_config_name='bots_check_html',
            num_participants=1,
            use_cli_bots=True,
            bot_case_number=0,
        )

        with self.settings(BOTS_CHECK_HTML=True):
            from django.conf import settings
            self.assertEqual(settings.BOTS_CHECK_HTML, True)

            bot_runner = session_bot_runner_factory(session)

            try:
                bot_runner.play()
            except AssertionError as exc:
                # AssertionError should say something about check_html
                raises_correct_message = 'check_html' in str(exc)
            else:
                raises_correct_message = False
            if not raises_correct_message:
                raise AssertionError('bots check_html not working properly')
Beispiel #6
0
def run_bots(session_config_name, num_participants):
    session = create_session(session_config_name,
                             num_participants=num_participants,
                             use_cli_bots=True)
    bot_runner = session_bot_runner_factory(session)
    bot_runner.play()
Beispiel #7
0
 def setUp(self):
     call_command('create_session', 'i18n', "1")
     session = Session.objects.get()
     self.bot_runner = session_bot_runner_factory(session)
Beispiel #8
0
 def setUp(self):
     call_command('create_session', 'i18n', "1")
     session = Session.objects.get()
     self.bot_runner = session_bot_runner_factory(session)
Beispiel #9
0
 def setUp(self):
     session = create_session('i18n', num_participants=1, use_cli_bots=True)
     self.bot_runner = session_bot_runner_factory(session)
Beispiel #10
0
 def setUp(self):
     session = create_session('i18n', num_participants=1, use_cli_bots=True)
     self.bot_runner = session_bot_runner_factory(session)
Beispiel #11
0
def run_bots(session_config_name, num_participants):
    session = create_session(
        session_config_name, num_participants=num_participants, use_cli_bots=True)
    bot_runner = session_bot_runner_factory(session)
    bot_runner.play()