示例#1
0
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'
示例#2
0
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)
示例#3
0
    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
示例#4
0
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
示例#5
0
def test_set_list(import_lists):
    lists.set_list('list3', ['six', 'seven'])
    assert lists.get_list('list3') == ['six', 'seven']
示例#6
0
 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
示例#7
0
 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)