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()
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()
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"]
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
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
def resave(): # when index mappings are changed logger = logging.getLogger("resave") for smartapi in SmartAPI.get_all(1000): logger.info(smartapi._id) smartapi.save()