mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-10-28 04:52:07 +00:00
* stash some changes * add more robust testing * mypy * point PR at V5 * introduce spec file * codespell * test fix * fix workflow environment setup * fix workflow environment setup * fix workflow environment setup * add pyyaml to dependencies * split lint jobs * fix workflow environment setup * fix workflow environment setup * workflow env setup * workflow env setup * clean up code comments * add auth hook entrypoints * codespell * add codegen feature * codespell * move _unpack into dispatchers for consistency with codegen packages * surface nested models in the response * fix missing coverage in CI * socrata updates * test fix * detect plotly output * add --include and --exclude flags from generate-extension command * cap test matrix at python 3.14 * no useless comments * platform controller command description split * merge URL overloads from path params * exclude none and unset from model dump --------- Co-authored-by: deeleeramone <> Co-authored-by: Copilot <copilot@github.com>
49 lines
1.6 KiB
Python
49 lines
1.6 KiB
Python
"""Test the obbject registry."""
|
|
|
|
from openbb_core.app.model.obbject import OBBject
|
|
|
|
from openbb_cli.argparse_translator.obbject_registry import Registry
|
|
|
|
# ruff: noqa: F841
|
|
|
|
|
|
def test_registry_operations():
|
|
"""Test the registry operations."""
|
|
registry = Registry()
|
|
obbject1 = OBBject(
|
|
id="1", results=True, extra={"register_key": "key1", "command": "cmd1"}
|
|
)
|
|
obbject2 = OBBject(
|
|
id="2", results=True, extra={"register_key": "key2", "command": "cmd2"}
|
|
)
|
|
obbject3 = OBBject( # noqa: F841
|
|
id="3", results=True, extra={"register_key": "key3", "command": "cmd3"}
|
|
)
|
|
|
|
assert registry.register(obbject1) is True
|
|
assert registry.register(obbject2) is True
|
|
assert registry.register(obbject1) is False
|
|
assert len(registry.obbjects) == 2
|
|
|
|
assert registry.get(0) == obbject2
|
|
assert registry.get(1) == obbject1
|
|
assert registry.get("key1") == obbject1
|
|
assert registry.get("key2") == obbject2
|
|
assert registry.get(2) is None
|
|
assert registry.get("invalid_key") is None
|
|
|
|
registry.remove(0)
|
|
assert len(registry.obbjects) == 1
|
|
assert registry.get("key2") is None
|
|
|
|
all_obbjects = registry.all
|
|
# ``command`` lives under ``extra`` — that's where the OBBject keeps
|
|
# it and where the registry surfaces it (no synthetic top-level
|
|
# mirror that would duplicate ``extra.metadata.route`` etc.).
|
|
assert "command" in all_obbjects[0]["extra"]
|
|
assert all_obbjects[0]["extra"]["command"] == "cmd1"
|
|
|
|
registry.remove()
|
|
assert len(registry.obbjects) == 0
|
|
assert registry.get("key1") is None
|