def test_parse_user_by_email(): user = get_user(make_connection_parser().parse_args( ['-u', '*****@*****.**'])) expected = User('*****@*****.**', alias='*****@*****.**', host='platform.genestack.org') assert user == expected
def test_token_without_username(): parser = make_connection_parser() some_token = 'some_token' args = parser.parse_args(['--token', some_token]) user = get_user(args) assert user.token == some_token assert user.host == DEFAULT_HOST
def test_parse_default_user(): user = get_user(make_connection_parser().parse_args()) expected = User('*****@*****.**', alias='tester', host='localhost:8080', password='******', token=None) assert user == expected
#!/usr/bin/env python2.7 # -*- coding: utf-8 -*- import os import sys import pytest sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..')) from genestack_client import (Connection, GenestackAuthenticationException, GenestackConnectionFailure, GenestackResponseError, get_user, GenestackException) from genestack_client.settings.genestack_user import _get_server_url wrong_url = 'http://localhost:9999/aaaaz' user = get_user() server_url = _get_server_url(user.host) user_login = user.email user_pwd = user.password def test_connection_to_wrong_url(): with pytest.raises(GenestackConnectionFailure, match='<connection failed '): connection = Connection(wrong_url) connection.login(user_login, user_pwd) def test_connection_404(): with pytest.raises(GenestackResponseError, match='<urlopen error 404 Client Error: Not Found for url:'):
# actual or intended publication of such source code. # import os import sys from urllib2 import URLError import pytest sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..')) from genestack_client import Connection, GenestackException from genestack_client import get_user from genestack_client.settings.genestack_user import _get_server_url wrong_url = 'http://localhost:9999/aaaaz' user = get_user() server_url = _get_server_url(user.host) user_login = user.email user_pwd = user.password def test_connection_to_wrong_url(): with pytest.raises(URLError): connection = Connection(wrong_url) connection.login(user_login, user_pwd) def test_login_positive(): connection = Connection(server_url) connection.login(user_login, user_pwd)
def conn(args): if get_user(args).host != "internal-dev.genestack.com": sys.stderr.write("Tests must be run on internal-dev") sys.exit(1) connection = get_connection(args) return connection
def test_parse_user_by_email(): user = get_user(make_connection_parser().parse_args(['-u', '*****@*****.**'])) expected = User('*****@*****.**', alias='*****@*****.**', host='platform.genestack.org') assert user == expected