Files
OpenBB/cli/integration/test_integration_obbject_registry.py
Theodore Aptekarev c63b3c8bab Security updates (#6531)
* Bump website deps to patched versions

* Drop support for python 3.8

* Bump scikit-learn to a patched version

* Run urllib3 update on lock files

* Bump ipykernel that brings in tornado to devtools

* Apply braces patch in frontend-components

* Drop python 3.8 from devtools support

* Bump dev environment to python >=3.10 to get rid of ullib3 v1 in lock files

* Downgrade and pin numpy to 1.x until pandas-ta supports 2.x

* Bump runners checkout and cache actions and python version

* Fix platform hub integration test

* Update dev install script to allow python 3.9

* Bump actions to versions that use node 20 vs node 16

* Bump exchange calendars package to resolve deprecation warnings

* Resolve bugs highlighted by the tests (#6538)

* Fix FMP currency snapshot model after a security update

* fixes

* add to the commit

* lint

---------

Co-authored-by: Danglewood <85772166+deeleeramone@users.noreply.github.com>

* Bump finviz

* Remove website folder that was added by merge conflict resolution

* update test cassettes

* biztoc test

* fix most of test_charting

* bump yfinance

* reference.json

* Fix some tests

* Enable 3.12 support

* Have 2 sets of cassettes for 2 versions of urlib3

* Allow 3.12 for sec provider

* add json_schema_extra choices to compare groups

* sorted choices

* test fixing: cassetes

* fix charting test

* black

* headers in sec download zip file

* Delete yaml

* lint

* lint

* Record https test_sec_compare_company_facts_fetcher

* Record https test_sec_compare_company_facts_fetcher, new params

* Record test in 3.9 and 3.10

* Record yfinance tests

* Record 310 with us vpn

* Record tests individually

* record without cache

* record without cache

---------

Co-authored-by: Danglewood <85772166+deeleeramone@users.noreply.github.com>
Co-authored-by: hjoaquim <henriquecjoaquim@gmail.com>
Co-authored-by: Igor Radovanovic <74266147+IgorWounds@users.noreply.github.com>
Co-authored-by: Diogo Sousa <montezdesousa@gmail.com>
2024-07-01 13:05:59 +00:00

55 lines
1.7 KiB
Python

"""Test the obbject registry."""
from openbb_cli.argparse_translator.obbject_registry import Registry
from openbb_core.app.model.obbject import OBBject
# pylint: disable=unused-variable
# ruff: noqa: disable=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"}
)
# Add obbjects to the registry
assert registry.register(obbject1) is True
assert registry.register(obbject2) is True
# Attempt to add the same object again
assert registry.register(obbject1) is False
# Ensure the registry size is correct
assert len(registry.obbjects) == 2
# Get by index
assert registry.get(0) == obbject2
assert registry.get(1) == obbject1
# Get by key
assert registry.get("key1") == obbject1
assert registry.get("key2") == obbject2
# Invalid index/key
assert registry.get(2) is None
assert registry.get("invalid_key") is None
# Remove an object
registry.remove(0)
assert len(registry.obbjects) == 1
assert registry.get("key2") is None
# Validate the 'all' property
all_obbjects = registry.all
assert "command" in all_obbjects[0]
assert all_obbjects[0]["command"] == "cmd1"
# Clean up by removing all objects
registry.remove()
assert len(registry.obbjects) == 0
assert registry.get("key1") is None