Ejemplo n.º 1
0
 def test_smartfetch_ok(self):
     """[summary]
     """
     with patch('requests.post') as mock_requests:
         mock_requests.return_value.status_code = 200
         smart_fetch = SmartFetch('')
         smart_fetch.post(code=200)
         self.assertIsInstance(smart_fetch, SmartFetch)
Ejemplo n.º 2
0
def test_smartfetch_fails():
    """[summary]
    """
    with patch('requests.post') as mock_requests:
        mock_requests.return_value.status_code = 200
        smart_fetch = SmartFetch('')
        value = smart_fetch.post(code=200)
        assert value.status_code == 200
        
Ejemplo n.º 3
0
 def test_smartfetch_fails(self):
     """
     Test that errors are properly raised on a failed request.
     """
     with patch('requests.post') as mock_requests:
         mock_requests.return_value.status_code = 200
         with self.assertRaises(RuntimeError):
             smart_fetch = SmartFetch('')
             smart_fetch.post(code=300)
Ejemplo n.º 4
0
from cidc_utils.requests import SmartFetch

from constants import EVE_URL

EVE_FETCHER = SmartFetch(EVE_URL)


def fetch_assays(jwt: str) -> dict:
    """
    Fetch all available assays in the system.

    Arguments:
        jwt {str} -- Requestor's JWT

    Returns:
        dict -- Assay records.
    """
    users_response = EVE_FETCHER.get(token=jwt, endpoint="assays")
    user_list = users_response.json()["_items"]

    return user_list
Ejemplo n.º 5
0
import logging
import json
from ftplib import FTP
import gzip
from io import BytesIO
from typing import List
from cidc_utils.requests import SmartFetch
from framework.celery.celery import APP
from framework.tasks.authorized_task import AuthorizedTask
from framework.tasks.variables import EVE_URL
from framework.tasks.parallelize_tasks import execute_in_parallel

HUGO_URL = "ftp.ncbi.nlm.nih.gov"
HUGO_DIRECTORY = "gene/DATA/GENE_INFO/Mammalia"
HUGO_FILE_NAME = "Homo_sapiens.gene_info.gz"
EVE = SmartFetch(EVE_URL)
IDENTIFIER_FIELDS = [
    {
        "key": 2,
        "is_array": False
    },  # Symbol
    {
        "key": 4,
        "is_array": True
    },  # Synonyms
    {
        "key": 10,
        "is_array": False
    },  # Symbol_from_nomenclature_authority
]
Ejemplo n.º 6
0
def test_smartfetch_instatiate():
    """
    Test the creation of a new SmartFetch object.
    """
    smart_fetch = SmartFetch('')
    assert smart_fetch.base_url == ''