Build applications that make decisions (chatbots, agents, simulations, etc...). Monitor, trace, persist, and execute on your own infrastructure.
Python aiburrchatbot-frameworkdagsgenerative-aigraphshacktoberfestllmopsllmsmlopspersistent-data-structurestate-machinestate-managementvisibility
added test for None value and type annotations
ziltob6ecd8ed661e
diff --git a/burr/core/persistence.py b/burr/core/persistence.pyindex 0b779f26..287d861f 100644--- a/burr/core/persistence.py+++ b/burr/core/persistence.py@@ -208,7 +208,11 @@ class SQLLitePersister(BaseStatePersister):return app_idsdef load(- self, partition_key: Optional[str], app_id: str, sequence_id: int = None, **kwargs+ self,+ partition_key: Optional[str],+ app_id: Optional[str],+ sequence_id: Optional[int] = None,+ **kwargs,) -> Optional[PersistedStateData]:"""Loads state for a given partition id.@@ -262,7 +266,7 @@ class SQLLitePersister(BaseStatePersister):def save(self,- partition_key: str,+ partition_key: Optional[str],app_id: str,sequence_id: int,position: str,diff --git a/tests/core/test_persistence.py b/tests/core/test_persistence.pyindex c8753d9f..7f7acc0d 100644--- a/tests/core/test_persistence.py+++ b/tests/core/test_persistence.py@@ -33,3 +33,31 @@ def test_persistence_lists_app_ids(persistence):persistence.save("partition_key", "app_id2", 1, "position", State({"key": "value"}), "status")app_ids = persistence.list_app_ids("partition_key")assert set(app_ids) == set(["app_id1", "app_id2"])+++ "method_name,kwargs",+ [+ ("list_app_ids", {"partition_key": None}),+ ("load", {"partition_key": None, "app_id": "foo"}),+ (+ "save",+ {+ "partition_key": None,+ "app_id": "foo",+ "sequence_id": 1,+ "position": "position",+ "state": State({"key": "value"}),+ "status": "status",+ },+ ),+ ],+)+def test_persister_methods_none_partition_key(persistence, method_name: str, kwargs: dict):+ persistence.initialize()+ method = getattr(persistence, method_name)+ # method can be executed with `partition_key=None`+ method(**kwargs)+ # this doesn't guarantee that the results of `partition_key=None` and+ # `partition_key=persistence.PARTITION_KEY_DEFAULT`. This is hard to test because+ # these operations are stateful (i.e., read/write to a db)