def test_time_measurement():
    connection = Connection(server_url)
    connection.login(user_login, user_pwd)
    response = connection.application('genestack/signin').get_response('whoami', trace=True)
    assert isinstance(response.trace, list)
    assert isinstance(response.elapsed_microseconds, int)
    assert response.elapsed_microseconds > 0
示例#2
0
    def get_connection(self, interactive=True, debug=False, show_logs=False):
        """
        Return a logged-in connection for current user.
        If ``interactive`` is ``True`` and the password or email are unknown,
        they will be asked in interactive mode.
        If no host is specified, the ``DEFAULT_HOST`` will be used.

        :param interactive: ask email and/or password interactively.
        :type interactive: bool
        :param debug: print stack trace in case of exception
        :type debug: bool
        :param show_logs: print application logs (received from server)
        :type show_logs: bool
        :return: logged connection
        :rtype: genestack_client.Connection
        """
        connection = Connection(_get_server_url(self.host), debug=debug, show_logs=show_logs)
        if self.token:
            connection.login_by_token(self.token)
        elif self.email and self.password:
            connection.login(self.email, self.password)
        elif interactive:
            self.__interactive_login(connection)
        #else:
        #    raise GenestackException('Not enough user data to login')
        return connection
def test_time_measurement():
    connection = Connection(server_url)
    connection.login(user_login, user_pwd)
    response = connection.application('genestack/signin').get_response(
        'whoami', trace=True)
    assert isinstance(response.trace, list)
    assert isinstance(response.elapsed_microseconds, int)
    assert response.elapsed_microseconds > 0
示例#4
0
def test_wrong_login():
    connection = Connection(server_url)
    with pytest.raises(GenestackException):
        connection.login("test", 'test')

    with pytest.raises(GenestackException):
        connection.login(user_login, user_login)

    with pytest.raises(GenestackException):
        connection.login(user_pwd, user_pwd)
def test_login_negative():
    connection = Connection(server_url)
    with pytest.raises(GenestackAuthenticationException,
                       match='Fail to login with "test" to "localhost"'):
        connection.login('test', 'test')

    with pytest.raises(GenestackAuthenticationException):
        connection.login(user_login, user_login)

    with pytest.raises(GenestackAuthenticationException):
        connection.login(user_pwd, user_pwd)
示例#6
0
    def get_connection(self, interactive=True):
        """
        Return a logged connection for current user.
        If ``interactive`` is True and the password or email are unknown, they will be asked in interactive mode.
        If no host is specified, the ``DEFAULT_HOST`` will be used.

        :param interactive: ask email and/or password interactively.
        :type interactive: bool
        :return: logged connection
        :rtype: :py:class:`~genestack_client.Connection.Connection`
        """
        connection = Connection(_get_server_url(self.host))
        if self.email and self.password:
            connection.login(self.email, self.password)
        elif interactive:
            self.__interactive_login(connection)
        else:
            raise GenestackException("Not enough user data to login")
        return connection
示例#7
0
    def get_connection(self, interactive=True):
        """
        Return a logged connection for current user.
        If ``interactive`` is True and the password or email are unknown, they will be asked in interactive mode.
        If no host is specified, the ``DEFAULT_HOST`` will be used.

        :param interactive: ask email and/or password interactively.
        :type interactive: bool
        :return: logged connection
        :rtype: :py:class:`~genestack_client.Connection.Connection`
        """
        connection = Connection(_get_server_url(self.host))
        if self.email and self.password:
            connection.login(self.email, self.password)
        elif interactive:
            self.__interactive_login(connection)
        else:
            raise GenestackException('Not enough user data to login')
        return connection
    def get_connection(self, interactive=True, debug=False, show_logs=False):
        """
        Return a logged-in connection for current user.
        If ``interactive`` is ``True`` and the password or email are unknown,
        they will be asked in interactive mode.
        If no host is specified, the ``DEFAULT_HOST`` will be used.

        :param interactive: ask email and/or password interactively.
        :type interactive: bool
        :param debug: print stack trace in case of exception
        :type debug: bool
        :param show_logs: print application logs (received from server)
        :type show_logs: bool
        :return: logged connection
        :rtype: genestack_client.Connection
        """
        connection = Connection(_get_server_url(self.host),
                                debug=debug,
                                show_logs=show_logs)
        if self.token:
            connection.login_by_token(self.token)
        elif self.email and self.password:
            connection.login(self.email, self.password)
        elif interactive:
            self.__interactive_login(connection)
        #else:
        #    raise GenestackException('Not enough user data to login')
        return connection
def test_login_negative():
    connection = Connection(server_url)
    with pytest.raises(GenestackAuthenticationException,
                       match='Fail to login with "test" to "localhost"'):
        connection.login('test', 'test')

    with pytest.raises(GenestackAuthenticationException):
        connection.login(user_login, user_login)

    with pytest.raises(GenestackAuthenticationException):
        connection.login(user_pwd, user_pwd)
示例#10
0
def test_access_by_anonymous():
    connection = Connection(server_url)
    with pytest.raises(GenestackException,
                       match="Cannot parse content: No JSON object could be decoded"):
        connection.perform_request('/')
示例#11
0
def test_login_by_password_positive():
    connection = Connection(server_url)
    connection.login(user_login, user_pwd)
    name = connection.application('genestack/signin').invoke('whoami')
    assert name == user_login, 'Name ("%s") does not match login ("%s")' % (name, user_login)
示例#12
0
def test_connection_to_wrong_url():
    with pytest.raises(GenestackConnectionFailure, match='<connection failed '):
        connection = Connection(wrong_url)
        connection.login(user_login, user_pwd)
示例#13
0
def test_connection_404():
    with pytest.raises(GenestackResponseError,
                       match='<urlopen error 404 Client Error: Not Found for url:'):
        connection = Connection(server_url)
        connection.perform_request('/hhhh')
示例#14
0
def test_open():
    connection = Connection(server_url)
    connection.login(user_login, user_pwd)
    connection.open('/')
示例#15
0
def test_connection_to_wrong_url():
    with pytest.raises(GenestackConnectionFailure,
                       match='<connection failed '):
        connection = Connection(wrong_url)
        connection.login(user_login, user_pwd)
示例#16
0
def test_connection_404():
    with pytest.raises(
            GenestackResponseError,
            match='<urlopen error 404 Client Error: Not Found for url:'):
        connection = Connection(server_url)
        connection.perform_request('/hhhh')
示例#17
0
def test_method_forbidden_for_anonymous():
    connection = Connection(server_url)
    with pytest.raises(GenestackAuthenticationException) as e:
        connection.application('genestack/signin').invoke('whoami')
示例#18
0
def test_login_by_password_positive():
    connection = Connection(server_url)
    connection.login(user_login, user_pwd)
    name = connection.application('genestack/signin').invoke('whoami')
    assert name == user_login, 'Name ("%s") does not match login ("%s")' % (
        name, user_login)
示例#19
0
def test_method_forbidden_for_anonymous():
    connection = Connection(server_url)
    with pytest.raises(GenestackAuthenticationException) as e:
        connection.application('genestack/signin').invoke('whoami')
示例#20
0
def test_access_by_anonymous():
    connection = Connection(server_url)
    with pytest.raises(
            GenestackException,
            match="Cannot parse content: No JSON object could be decoded"):
        connection.perform_request('/')
示例#21
0
def test_connection_to_wrong_url():
    with pytest.raises(URLError):
        connection = Connection(wrong_url)
        connection.login(user_login, user_pwd)
示例#22
0
def test_login_positive():
    connection = Connection(server_url)
    connection.login(user_login, user_pwd)
    name = connection.application('genestack/signin').invoke('whoami')
    assert name == user_login, "Name does not match %s and  %s" % (name,
                                                                   user_login)