Skip to content

Commit

Permalink
Add a test that checks whether at least one database can be found in …
Browse files Browse the repository at this point in the history
…OPTIMADE consortia
  • Loading branch information
ml-evs committed Nov 5, 2023
1 parent 2970d9a commit edf65c8
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
1 change: 0 additions & 1 deletion optimade/client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,6 @@ def __init__(
progress=progress,
)
)
print(self.base_urls)
else:
if exclude_providers or include_providers or exclude_databases:
raise RuntimeError(
Expand Down
3 changes: 3 additions & 0 deletions optimade/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,9 @@ def get_all_databases(
)
else:
progress = contextlib.nullcontext()
progress.print = lambda _: None # type: ignore[attr-defined]
progress.advance = lambda *_: None # type: ignore[attr-defined]
_task = None

with progress:
for provider in get_providers():
Expand Down
9 changes: 9 additions & 0 deletions tests/server/routers/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ def __init__(self, data: Union[list, dict], status_code: int):
def json(self) -> Union[list, dict]:
return self.data

def content(self) -> str:
return str(self.data)

return MockResponse(providers, 200)


Expand Down Expand Up @@ -73,6 +76,12 @@ def test_get_providers():
assert get_providers() == providers_list


def test_get_all_databases():
from optimade.utils import get_all_databases

assert list(get_all_databases())


def test_get_providers_warning(caplog, top_dir):
"""Make sure a warning is logged as a last resort."""
import copy
Expand Down

0 comments on commit edf65c8

Please sign in to comment.