diff --git a/tests/test_cache.py b/tests/test_cache.py index 50698c304..94e4e8553 100644 --- a/tests/test_cache.py +++ b/tests/test_cache.py @@ -1,5 +1,6 @@ import json from langflow.graph import Graph +from langflow.services.cache.utils import compute_dict_hash import pytest from langflow.interface.run import ( @@ -41,8 +42,9 @@ def langchain_objects_are_equal(obj1, obj2): # Test build_langchain_object_with_caching -def test_build_langchain_object_with_caching(basic_data_graph): - build_langchain_object_with_caching.clear_cache() +def test_build_langchain_object_with_caching(client, basic_data_graph): + session_id = compute_dict_hash(basic_data_graph) + build_langchain_object_with_caching.clear_cache(session_id) graph = build_langchain_object_with_caching(basic_data_graph) assert graph is not None @@ -53,19 +55,3 @@ def test_build_graph(basic_data_graph): assert graph is not None assert len(graph.nodes) == len(basic_data_graph["nodes"]) assert len(graph.edges) == len(basic_data_graph["edges"]) - - -# Test cache size limit -def test_cache_size_limit(basic_data_graph): - build_langchain_object_with_caching.clear_cache() - for i in range(11): - modified_data_graph = basic_data_graph.copy() - nodes = modified_data_graph["nodes"] - node_id = nodes[0]["id"] - # Now we replace all instances ode node_id with a new id in the json - json_string = json.dumps(modified_data_graph) - modified_json_string = json_string.replace(node_id, f"{node_id}_{i}") - modified_data_graph_new_id = json.loads(modified_json_string) - build_langchain_object_with_caching(modified_data_graph_new_id) - - assert len(build_langchain_object_with_caching.cache) == 10 diff --git a/tests/test_cache_manager.py b/tests/test_cache_manager.py index 660512634..a560aff88 100644 --- a/tests/test_cache_manager.py +++ b/tests/test_cache_manager.py @@ -2,7 +2,7 @@ from io import StringIO import pandas as pd import pytest -from langflow.services.cache.manager import CacheManager +from langflow.services.chat.cache import CacheManager from PIL import Image diff --git a/tests/test_cli.py b/tests/test_cli.py index 408500d7a..c990ef9e8 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -27,4 +27,4 @@ def test_components_path(runner, client, default_settings): ) assert result.exit_code == 0, result.stdout settings_manager = utils.get_settings_manager() - assert temp_dir in settings_manager.settings.COMPONENTS_PATH + assert str(temp_dir) in settings_manager.settings.COMPONENTS_PATH diff --git a/tests/test_process.py b/tests/test_process.py index a0d91b5df..29c125abf 100644 --- a/tests/test_process.py +++ b/tests/test_process.py @@ -218,7 +218,7 @@ def test_load_langchain_object_with_no_cached_session(client, basic_graph_data): basic_graph_data, "non_existent_session" ) # Clear the cache - build_sorted_vertices_with_caching.clear_cache() + build_sorted_vertices_with_caching.clear_cache(session_id1) # Use the new session_id to get the langchain_object again langchain_object2, artifacts2, session_id2 = load_langchain_object( basic_graph_data, session_id1