Skip to content

Commit 3085de5

Browse files
committed
fix does_key_exist_in_hashmap + test
1 parent 3d2ed2a commit 3085de5

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

conda_forge_tick/lazy_json_backends.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -638,7 +638,7 @@ def does_key_exist_in_hashmap(name: str, key: str) -> bool:
638638
:return: True if the key exists, False otherwise.
639639
"""
640640
backend = LAZY_JSON_BACKENDS[CF_TICK_GRAPH_DATA_PRIMARY_BACKEND]()
641-
return backend.hexists(key, name)
641+
return backend.hexists(name, key)
642642

643643

644644
@contextlib.contextmanager

tests/test_lazy_json_backends.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
GithubLazyJsonBackend,
1717
LazyJson,
1818
MongoDBLazyJsonBackend,
19+
does_key_exist_in_hashmap,
1920
dump,
2021
dumps,
2122
get_all_keys_for_hashmap,
@@ -604,6 +605,17 @@ def test_lazy_json_backends_hashmap(tmpdir):
604605
assert get_all_keys_for_hashmap("lazy_json") == []
605606

606607

608+
def test_does_key_exist_in_hashmap(tmpdir):
609+
with pushd(tmpdir):
610+
LazyJson("vanilla.json")
611+
LazyJson("node_attrs/chocolate.json")
612+
LazyJson("versions/strawberry.json")
613+
614+
assert does_key_exist_in_hashmap("node_attrs", "chocolate")
615+
assert not does_key_exist_in_hashmap("node_attrs", "vanilla")
616+
assert not does_key_exist_in_hashmap("node_attrs", "strawberry")
617+
618+
607619
def test_github_base_url() -> None:
608620
github_backend = GithubLazyJsonBackend()
609621
assert github_backend.base_url == CF_TICK_GRAPH_GITHUB_BACKEND_BASE_URL + "/"

0 commit comments

Comments
 (0)