Example #1
0
 def get_num_bot_cases(self):
     num_cases = 1
     for app_name in self['app_sequence']:
         bots_module = get_bots_module(app_name)
         cases = bots_module.PlayerBot.cases
         num_cases = max(num_cases, len(cases))
     return num_cases
Example #2
0
 def get_num_bot_cases(self):
     num_cases = 1
     for app_name in self['app_sequence']:
         bots_module = get_bots_module(app_name)
         cases = bots_module.PlayerBot.cases
         num_cases = max(num_cases, len(cases))
     return num_cases
Example #3
0
    def __init__(self, participant, **kwargs):
        self.participant = participant
        self.url = None
        self._response = None
        self._html = None
        self.path = None
        self.submits = None
        super(ParticipantBot, self).__init__()

        self.player_bots = []
        for player in self.participant.get_players():
            bots_module = get_bots_module(player._meta.app_config.name)
            player_bot = bots_module.PlayerBot(player=player,
                                               participant_bot=self)
            self.player_bots.append(player_bot)
        self.submits_generator = self.get_submits()
Example #4
0
    def __init__(self,
                 participant: Participant = None,
                 *,
                 lookups: List[ParticipantToPlayerLookup] = None,
                 load_player_bots=True,
                 case_number=None):

        # usually lookups should be passed in. for ad-hoc testing,
        # ok to pass a participant
        if not lookups:
            lookups_with_duplicates = ParticipantToPlayerLookup.objects.filter(
                participant_id=participant.id).order_by('player_pk')
            seen_player_pks = set()
            lookups = []
            for lookup in lookups_with_duplicates:
                if not lookup.player_pk in seen_player_pks:
                    lookups.append(lookup)
                    seen_player_pks.add(lookup.player_pk)

        self.participant_id = lookups[0].participant_id
        self.participant_code = lookups[0].participant_code

        self.url = None
        self._response = None
        self._html = None
        self.form_errors = {}
        self.path = None
        self.submits = None
        super().__init__()

        self.player_bots = []

        # load_player_bots can be set to False when it's convenient for
        # internal testing
        if load_player_bots:
            for lookup in lookups:
                app_name = lookup.app_name
                bots_module = get_bots_module(app_name)
                player_bot = bots_module.PlayerBot(lookup=lookup,
                                                   case_number=case_number,
                                                   participant_bot=self)
                self.player_bots.append(player_bot)
            self.submits_generator = self.get_submits()
Example #5
0
    def __init__(
            self, participant: Participant=None, *,
            lookups: List[ParticipantToPlayerLookup] = None,
            load_player_bots=True, case_number=None
    ):
        # usually lookups should be passed in. for ad-hoc testing,
        # ok to pass a participant
        if not lookups:
            lookups_with_duplicates = ParticipantToPlayerLookup.objects.filter(
                participant_id=participant.id).order_by('player_pk')
            seen_player_pks = set()
            lookups = []
            for lookup in lookups_with_duplicates:
                if not lookup.player_pk in seen_player_pks:
                    lookups.append(lookup)
                    seen_player_pks.add(lookup.player_pk)

        self.participant_id = lookups[0].participant_id
        self.participant_code = lookups[0].participant_code

        if not lookups:
            lookups = []
        self.url = None
        self._response = None
        self._html = None
        self.path = None
        self.submits = None
        super().__init__()

        self.player_bots = []

        # load_player_bots can be set to False when it's convenient for
        # internal testing
        if load_player_bots:
            for lookup in lookups:
                app_name = lookup.app_name
                bots_module = get_bots_module(app_name)
                player_bot = bots_module.PlayerBot(
                    lookup=lookup, case_number=case_number,
                    participant_bot=self
                )
                self.player_bots.append(player_bot)
            self.submits_generator = self.get_submits()
Example #6
0
    def __init__(
            self, participant, load_player_bots=True, **kwargs):
        self.participant = participant
        self.url = None
        self._response = None
        self._html = None
        self.path = None
        self.submits = None
        super(ParticipantBot, self).__init__()

        self.player_bots = []

        # load_player_bots can be set to False when it's convenient for
        # internal testing
        if load_player_bots:
            for player in self.participant.get_players():
                bots_module = get_bots_module(player._meta.app_config.name)
                player_bot = bots_module.PlayerBot(
                    player=player,
                    participant_bot=self)
                self.player_bots.append(player_bot)
            self.submits_generator = self.get_submits()
Example #7
0
    def __init__(
            self, participant, load_player_bots=True, **kwargs):
        self.participant = participant
        self.url = None
        self._response = None
        self._html = None
        self.path = None
        self.submits = None
        super(ParticipantBot, self).__init__()

        self.player_bots = []

        # load_player_bots can be set to False when it's convenient for
        # internal testing
        if load_player_bots:
            for player in self.participant.get_players():
                bots_module = get_bots_module(player._meta.app_config.name)
                player_bot = bots_module.PlayerBot(
                    player=player,
                    participant_bot=self)
                self.player_bots.append(player_bot)
            self.submits_generator = self.get_submits()