def test_remove_from_list(import_lists): removed = lists.remove_from_list('list2', 0) expected_removed = 'four' assert removed == expected_removed assert lists.get_list('list2') == ['five'] # make sure the indexes are reset list_item = db.session.query(ListItem).filter_by(list_name='list2', index=0).first() assert list_item.item == 'five'
def get_list(): if request.method == 'POST': data = request.get_json() list_data = { 'name': data.get('name', '') } try: list_dict = lists.get_list(**list_data) except Exception as e: raise InvalidUsage(str(e)) return jsonify(list_dict)
def group_alert_api(self, user, badges, group_alert): if user in lists.get_list('banned_users'): return elif not self._badge_check(badges, Badges.VIP) and self.spamming(user): self.chat('No spamming {}. Wait another {} seconds.'.format(user, self.timeout)) return try: alerts.group_alert(group_name=group_alert, chat=True) except Exception: pass
def fake_group_alert_api(cls, user, badges, group_alert): if user in lists.get_list('banned_users'): return elif not cls._badge_check(badges, models.Badges.VIP) and cls.spamming(user): cls.chat('No spamming {}. Wait another {} seconds.'.format( user, cls.timeout)) return try: alerts.group_alert(group_name=group_alert, hit_socket=False, chat=True) except Exception as e: pass
def test_set_list(import_lists): lists.set_list('list3', ['six', 'seven']) assert lists.get_list('list3') == ['six', 'seven']
def unban(self, unban_user): if unban_user: banned_users = lists.get_list('banned_users') lists.set_list('banned_users', [user for user in banned_users if user != unban_user]) self.chat('Unbanned {}'.format(unban_user)) return unban_user
def add_list_item(self, list_name, item): index = len(lists.get_list(list_name)) + 1 lists.add_to_list(list_name, [item]) self.output_list_item(index, item)