Skip to content

Commit

Permalink
tests: add context manager test
Browse files Browse the repository at this point in the history
  • Loading branch information
jjjermiah committed Feb 18, 2024
1 parent fab5dcc commit c14bd6f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 15 deletions.
15 changes: 0 additions & 15 deletions src/nbiatoolkit/nbia.py
Original file line number Diff line number Diff line change
Expand Up @@ -542,18 +542,3 @@ def parsePARAMS(self, params: dict) -> dict:
if (value != "") and (key != "self") and (key != "return_type"):
PARAMS[key] = value
return PARAMS


# main
if __name__ == "__main__":
from pprint import pprint
import os

client = NBIAClient(log_level="info")

print(client.getStudies(Collection="TCGA-GBM"))
# all = client.getCollections()
# pprint(all)

# sub = client.getCollections(prefix="aCrin")
# pprint(sub)
14 changes: 14 additions & 0 deletions tests/test_tcga_collections_separate.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,20 @@ def tcga_collections(nbia_client):
return (tcga_collection_df, tcga_collections)


@pytest.fixture(scope="session")
def nbia_context_manager():
with NBIAClient(log_level="WARNING") as nbia_client:
yield nbia_client


def test_nbia_properties(nbia_context_manager):
assert isinstance(nbia_context_manager.OAuth_client, OAuth2)
assert isinstance(nbia_context_manager.headers, dict)
assert "Authorization" in nbia_context_manager.headers.keys()
assert "Content-Type" in nbia_context_manager.headers.keys()
assert nbia_context_manager.headers["Content-Type"] == "application/json"


def test_break(nbia_client_tobreak):
assert nbia_client_tobreak.base_url == NBIA_ENDPOINTS.NBIA
nbia_client_tobreak.base_url = NBIA_ENDPOINTS.NLST
Expand Down

0 comments on commit c14bd6f

Please sign in to comment.