def test_get(self):
        # Create the usernames key so we can do autocomplete
        r_client.zadd('qiita-usernames', **{u: 0 for u in User.iter()})
        response = self.get(self.base_url % 't')
        self.assertEqual(response.code, 200)
        self.assertEqual(
            loads(response.body),
            {'results': [{
                "id": "*****@*****.**",
                "text": "*****@*****.**"
            }]})

        response = self.get(self.base_url % 'admi')
        self.assertEqual(response.code, 200)
        self.assertEqual(
            loads(response.body),
            {'results': [{
                "id": "*****@*****.**",
                "text": "*****@*****.**"
            }]})

        response = self.get(self.base_url % 'tesq')
        self.assertEqual(response.code, 200)
        self.assertEqual(loads(response.body), {'results': []})

        r_client.delete('qiita-usernames')
Exemple #2
0
    def test_get(self):
        base_url = '/study/sharing/autocomplete/?text=%s'

        r_client.zadd('qiita-usernames', {e: 0 for e, n in User.iter()})
        response = self.get(base_url % 't')
        self.assertEqual(response.code, 200)
        self.assertEqual(
            loads(response.body),
            {'results': [{
                "id": "*****@*****.**",
                "text": "*****@*****.**"
            }]})

        response = self.get(base_url % 'admi')
        self.assertEqual(response.code, 200)
        self.assertEqual(
            loads(response.body),
            {'results': [{
                "id": "*****@*****.**",
                "text": "*****@*****.**"
            }]})

        response = self.get(base_url % 'tesq')
        self.assertEqual(response.code, 200)
        self.assertEqual(loads(response.body), {'results': []})

        r_client.delete('qiita-usernames')
Exemple #3
0
    def test_get(self):
        # Create the usernames key so we can do autocomplete
        r_client.zadd('qiita-usernames', **{u: 0 for u in User.iter()})
        response = self.get(self.base_url % 't')
        self.assertEqual(response.code, 200)
        self.assertEqual(loads(response.body),
                         {'results': [{"id": "*****@*****.**",
                                       "text": "*****@*****.**"}]})

        response = self.get(self.base_url % 'admi')
        self.assertEqual(response.code, 200)
        self.assertEqual(loads(response.body),
                         {'results': [{"id": "*****@*****.**",
                                       "text": "*****@*****.**"}]})

        response = self.get(self.base_url % 'tesq')
        self.assertEqual(response.code, 200)
        self.assertEqual(loads(response.body),
                         {'results': []})

        r_client.delete('qiita-usernames')
    def test_get(self):
        base_url = '/study/sharing/autocomplete/?text=%s'

        r_client.zadd('qiita-usernames', {e: 0 for e, n in User.iter()})
        response = self.get(base_url % 't')
        self.assertEqual(response.code, 200)
        self.assertEqual(loads(response.body),
                         {'results': [{"id": "*****@*****.**",
                                       "text": "*****@*****.**"}]})

        response = self.get(base_url % 'admi')
        self.assertEqual(response.code, 200)
        self.assertEqual(loads(response.body),
                         {'results': [{"id": "*****@*****.**",
                                       "text": "*****@*****.**"}]})

        response = self.get(base_url % 'tesq')
        self.assertEqual(response.code, 200)
        self.assertEqual(loads(response.body),
                         {'results': []})

        r_client.delete('qiita-usernames')
Exemple #5
0
 def _get_all_emails(self, callback):
     callback(list(User.iter()))
Exemple #6
0
 def _get_all_emails(self, callback):
     callback(list(User.iter()))
Exemple #7
0
from qiita_db.user import User
from json import loads, dumps

from qiita_core.qiita_settings import r_client
from qiita_db.sql_connection import TRN
from qiita_db.software import Software, Command
from qiita_db.exceptions import QiitaDBError, QiitaDBDuplicateError
from qiita_db.util import convert_to_id


# one of the main side issues raised by #2901 is that new users emails were not
# added to the redis database that keep track of emails and is used to
# autocomplete when sharing a study. In the next look we will find all `Users`
# in the `user` level, search them in the redis database, and keep those ones
# that are not found
missing_emails = [u[0] for u in User.iter() if User(u[0]).level == 'user'
                  and not r_client.execute_command(
                      'zrangebylex', 'qiita-usernames',
                      '[%s' % u[0], u'[%s\xff' % u[0])]

# now just add them
for email in missing_emails:
    r_client.zadd('qiita-usernames', {email: 0})


# adding new internal command for INSDC download
# note that create_command is a method that has been used in previous patches
def create_command(software, name, description, parameters, outputs=None,
                   analysis_only=False):
    r"""Replicates the Command.create code at the time the patch was written"""
    # Perform some sanity checks in the parameters dictionary
Exemple #8
0
 def _get_all_emails(self, callback):
     callback([email for email, name in User.iter()])
Exemple #9
0
 def _get_all_emails(self, callback):
     callback([email for email, name in User.iter()])