def test_search(self): client = DatasetClient() res = client.search("cancer human", "publication_date", "ascending") assert res.json()["count"] > 0 try: dataset = client.search("j9j9j9j9@£", "publication_date", "ascending") except BadRequest as err: assert err.status == DATA_NOT_FOUND try: dataset = client.search(None, "publication_date", "ascending") except BadRequest as err: assert err.status == MISSING_PARAMETER
def source_from_id(acc): client = DatasetClient() api_output = client.search(acc, "id") if api_output.datasets: datasets = api_output.datasets if len(datasets) > 1: hits = [] for dataset in datasets: if dataset.accession == acc: hits.append(dataset) if len(hits) == 1: source = hits[0].database return source else: click.echo('INFO') click.echo( f'{acc} is not a unique ID, leading to multiple hits.') sys.exit() else: source = datasets[0].database return source else: click.echo('INFO') click.echo(f'{acc} could not be found in one of the repositories.') sys.exit()
def test_search(self): client = DatasetClient() res = client.search("cancer human", "publication_date", "ascending") assert len(res.datasets) > 0 assert res.count > 0 res_other_pages = client.search("cancer human", "publication_date", "ascending", 1200, 30, 20) assert res_other_pages.count > 0 assert len(res_other_pages.datasets) == 30 try: dataset = client.search("j9j9j9j9@£", "publication_date", "ascending") except BadRequest as err: assert err.status == DATA_NOT_FOUND try: dataset = client.search(None, "publication_date", "ascending") except BadRequest as err: assert err.status == MISSING_PARAMETER