Example #1
0
def check_uptime():
    logger = logging.getLogger("uptime")
    for smartapi in SmartAPI.get_all(1000):
        logger.info(smartapi._id)
        _status = smartapi.check()
        logger.info(_status)
        smartapi.save()
Example #2
0
def refresh_document():
    logger = logging.getLogger("refresh")
    for smartapi in SmartAPI.get_all(1000):
        logger.info(smartapi._id)
        _status = smartapi.refresh()
        logger.info(_status)
        smartapi.save()
Example #3
0
def test_get_all():
    """
    SmartAPI.get_all()
    """
    docs = list(SmartAPI.get_all())
    assert len(docs) == 2
    assert docs[0]["info"]["title"] in ["MyGene.info API", "MyChem.info API"]
    assert docs[1]["info"]["title"] in ["MyGene.info API", "MyChem.info API"]
Example #4
0
def test_get_all_from():
    """
    SmartAPI.get_all(from_=1)
    """
    search = APIDoc.search()
    assert search.count() == 2

    docs = list(SmartAPI.get_all(from_=1))
    assert len(docs) == 1
Example #5
0
def _backup():
    smartapis = []
    for smartapi in SmartAPI.get_all(1000):
        smartapis.append({
            "url": smartapi.url,
            "username": smartapi.username,
            "slug": smartapi.slug,
            "date_created": smartapi.date_created.isoformat(),
            "last_updated": smartapi.last_updated.isoformat(),
            "raw": smartapi.raw.decode()  # to string
        })
    return smartapis
Example #6
0
def resave():
    # when index mappings are changed
    logger = logging.getLogger("resave")
    for smartapi in SmartAPI.get_all(1000):
        logger.info(smartapi._id)
        smartapi.save()