def test_send_gene_request():
    """Test send request with correct params and endpoint"""
    url = 'https://grch37.rest.ensembl.org/overlap/id/ENSG00000103591?feature=gene'
    client = eracs.EnsemblRestApiClient()
    data = client.send_request(url)
    # get all gene for the ensembl gene, They should be a list of items
    assert data[0]['assembly_name'] == 'GRCh37'
    assert data[0]['external_name'] == 'AAGAB'
    assert data[0]['start']
    assert data[0]['end']
def test_send_request_wrong_url():
    """Successful requests are tested by other tests in this file.
       This test will trigger errors instead.
    """
    url = 'fakeyurl'
    client = eracs.EnsemblRestApiClient()
    data = client.send_request(url)
    assert type(data) == ValueError

    url = 'https://grch37.rest.ensembl.org/fakeyurl'
    data = client.send_request(url)
    assert type(data) == HTTPError
def test_use_api():
    """Test the use_api method of the EnsemblRestClient"""

    endpoint = '/overlap/id/ENSG00000157764'
    params = {'feature': 'transcript'}
    client = eracs.EnsemblRestApiClient(build='38')

    # get all transctipts for an ensembl gene, They should be a list of items
    data = client.use_api(endpoint, params)
    assert data[0]['assembly_name'] == 'GRCh38'
    assert data[0]['feature_type'] == 'transcript'
    assert data[0]['id']
    assert data[0]['start']
    assert data[0]['strand']
Exemple #4
0
def test_use_api():
    """Test the use_api method of the EnsemblRestClient"""

    endpoint = "/overlap/id/ENSG00000157764"
    params = {"feature": "transcript"}
    client = eracs.EnsemblRestApiClient(build="38")

    # get all transctipts for an ensembl gene, They should be a list of items
    data = client.use_api(endpoint, params)
    assert data[0]["assembly_name"] == "GRCh38"
    assert data[0]["feature_type"] == "transcript"
    assert data[0]["id"]
    assert data[0]["start"]
    assert data[0]["strand"]
Exemple #5
0
def test_send_gene_request():
    """Test send request with correct params and endpoint"""
    url = "https://grch37.rest.ensembl.org/overlap/id/ENSG00000103591?feature=gene"
    client = eracs.EnsemblRestApiClient()

    try:
        data = client.send_request(url)
        # get all gene for the ensembl gene, They should be a list of items
        assert data[0]["assembly_name"] == "GRCh37"
        assert data[0]["external_name"] == "AAGAB"
        assert data[0]["start"]
        assert data[0]["end"]
    except Exception as ex:
        assert isinstance(data, HTTPError)  # service is down
Exemple #6
0
def ensembl_rest_client_38():
    """Return a client to the ensembl rest api, build 38"""
    return ensembl_rest_clients.EnsemblRestApiClient("38")
def test_ping_ensemble_37():
    """Test ping ensembl server containing human build 37"""
    client = eracs.EnsemblRestApiClient()
    data = client.ping_server()
    assert data == {'ping': 1}
Exemple #8
0
def test_ping_ensemble_38():
    """Test ping ensembl server containing human build 38"""
    client = eracs.EnsemblRestApiClient(build="38")
    data = client.ping_server()
    assert data == {"ping": 1}