test_filesystem.py — langchain Source File
Architecture documentation for test_filesystem.py, a python file in the langchain codebase. 6 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR dc21888b_994e_4dfd_2387_4da22b01f8de["test_filesystem.py"] fae55357_8e00_f092_b2c8_957d1841a180["tempfile"] dc21888b_994e_4dfd_2387_4da22b01f8de --> fae55357_8e00_f092_b2c8_957d1841a180 2bf6d401_816d_d011_3b05_a6114f55ff58["collections.abc"] dc21888b_994e_4dfd_2387_4da22b01f8de --> 2bf6d401_816d_d011_3b05_a6114f55ff58 927570d8_11a6_5c17_0f0d_80baae0c733e["pathlib"] dc21888b_994e_4dfd_2387_4da22b01f8de --> 927570d8_11a6_5c17_0f0d_80baae0c733e f69d6389_263d_68a4_7fbf_f14c0602a9ba["pytest"] dc21888b_994e_4dfd_2387_4da22b01f8de --> f69d6389_263d_68a4_7fbf_f14c0602a9ba 18bf18ce_a804_12d4_efe2_700bc6c22630["langchain_core.stores"] dc21888b_994e_4dfd_2387_4da22b01f8de --> 18bf18ce_a804_12d4_efe2_700bc6c22630 3aee0ef4_247b_eb87_d928_fcb84571e1c1["langchain_classic.storage.file_system"] dc21888b_994e_4dfd_2387_4da22b01f8de --> 3aee0ef4_247b_eb87_d928_fcb84571e1c1 style dc21888b_994e_4dfd_2387_4da22b01f8de fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import tempfile
from collections.abc import Generator
from pathlib import Path
import pytest
from langchain_core.stores import InvalidKeyException
from langchain_classic.storage.file_system import LocalFileStore
@pytest.fixture
def file_store() -> Generator[LocalFileStore, None, None]:
# Create a temporary directory for testing
with tempfile.TemporaryDirectory() as temp_dir:
# Instantiate the LocalFileStore with the temporary directory as the root path
store = LocalFileStore(temp_dir)
yield store
def test_mset_and_mget(file_store: LocalFileStore) -> None:
# Set values for keys
key_value_pairs = [("key1", b"value1"), ("key2", b"value2")]
file_store.mset(key_value_pairs)
# Get values for keys
values = file_store.mget(["key1", "key2"])
# Assert that the retrieved values match the original values
assert values == [b"value1", b"value2"]
@pytest.mark.parametrize(
("chmod_dir_s", "chmod_file_s"),
[("777", "666"), ("770", "660"), ("700", "600")],
)
def test_mset_chmod(chmod_dir_s: str, chmod_file_s: str) -> None:
chmod_dir = int(chmod_dir_s, base=8)
chmod_file = int(chmod_file_s, base=8)
# Create a temporary directory for testing
with tempfile.TemporaryDirectory() as temp_dir:
# Instantiate the LocalFileStore with a directory inside the temporary directory
# as the root path
file_store = LocalFileStore(
Path(temp_dir) / "store_dir",
chmod_dir=chmod_dir,
chmod_file=chmod_file,
)
# Set values for keys
key_value_pairs = [("key1", b"value1"), ("key2", b"value2")]
file_store.mset(key_value_pairs)
# verify the permissions are set correctly
# (test only the standard user/group/other bits)
dir_path = file_store.root_path
file_path = file_store.root_path / "key1"
assert (dir_path.stat().st_mode & 0o777) == chmod_dir
assert (file_path.stat().st_mode & 0o777) == chmod_file
// ... (99 more lines)
Domain
Subdomains
Functions
Dependencies
- collections.abc
- langchain_classic.storage.file_system
- langchain_core.stores
- pathlib
- pytest
- tempfile
Source
Frequently Asked Questions
What does test_filesystem.py do?
test_filesystem.py is a source file in the langchain codebase, written in python. It belongs to the LangChainCore domain, Runnables subdomain.
What functions are defined in test_filesystem.py?
test_filesystem.py defines 9 function(s): file_store, test_catches_forbidden_keys, test_mdelete, test_mget_update_atime, test_mset_and_mget, test_mset_chmod, test_set_invalid_key, test_set_key_and_verify_content, test_yield_keys.
What does test_filesystem.py depend on?
test_filesystem.py imports 6 module(s): collections.abc, langchain_classic.storage.file_system, langchain_core.stores, pathlib, pytest, tempfile.
Where is test_filesystem.py in the architecture?
test_filesystem.py is located at libs/langchain/tests/unit_tests/storage/test_filesystem.py (domain: LangChainCore, subdomain: Runnables, directory: libs/langchain/tests/unit_tests/storage).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free