Home / File/ test_in_memory_record_manager.py — langchain Source File

test_in_memory_record_manager.py — langchain Source File

Architecture documentation for test_in_memory_record_manager.py, a python file in the langchain codebase. 5 imports, 0 dependents.

Entity Profile

Dependency Diagram

graph LR
  0a49adf9_8741_0192_f95b_5cb8cd00ab22["test_in_memory_record_manager.py"]
  af34f08b_0ede_2b87_0db6_983d74ed0249["datetime"]
  0a49adf9_8741_0192_f95b_5cb8cd00ab22 --> af34f08b_0ede_2b87_0db6_983d74ed0249
  525a7d6f_f455_56e3_854a_c8a7da4a1417["unittest.mock"]
  0a49adf9_8741_0192_f95b_5cb8cd00ab22 --> 525a7d6f_f455_56e3_854a_c8a7da4a1417
  120e2591_3e15_b895_72b6_cb26195e40a6["pytest"]
  0a49adf9_8741_0192_f95b_5cb8cd00ab22 --> 120e2591_3e15_b895_72b6_cb26195e40a6
  a3f8313e_187d_b883_54b8_d68ee753b3c6["pytest_asyncio"]
  0a49adf9_8741_0192_f95b_5cb8cd00ab22 --> a3f8313e_187d_b883_54b8_d68ee753b3c6
  a8fcc022_dc2b_29f4_4e44_b5c75941d529["langchain_core.indexing"]
  0a49adf9_8741_0192_f95b_5cb8cd00ab22 --> a8fcc022_dc2b_29f4_4e44_b5c75941d529
  style 0a49adf9_8741_0192_f95b_5cb8cd00ab22 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

from datetime import datetime, timezone
from unittest.mock import patch

import pytest
import pytest_asyncio

from langchain_core.indexing import InMemoryRecordManager


@pytest.fixture
def manager() -> InMemoryRecordManager:
    """Initialize the test database and yield the TimestampedSet instance."""
    # Initialize and yield the TimestampedSet instance
    record_manager = InMemoryRecordManager(namespace="kittens")
    record_manager.create_schema()
    return record_manager


@pytest_asyncio.fixture()
async def amanager() -> InMemoryRecordManager:
    """Initialize the test database and yield the TimestampedSet instance."""
    # Initialize and yield the TimestampedSet instance
    record_manager = InMemoryRecordManager(namespace="kittens")
    await record_manager.acreate_schema()
    return record_manager


def test_update(manager: InMemoryRecordManager) -> None:
    """Test updating records in the database."""
    # no keys should be present in the set
    read_keys = manager.list_keys()
    assert read_keys == []
    # Insert records
    keys = ["key1", "key2", "key3"]
    manager.update(keys)
    # Retrieve the records
    read_keys = manager.list_keys()
    assert read_keys == ["key1", "key2", "key3"]


async def test_aupdate(amanager: InMemoryRecordManager) -> None:
    """Test updating records in the database."""
    # no keys should be present in the set
    read_keys = await amanager.alist_keys()
    assert read_keys == []
    # Insert records
    keys = ["key1", "key2", "key3"]
    await amanager.aupdate(keys)
    # Retrieve the records
    read_keys = await amanager.alist_keys()
    assert read_keys == ["key1", "key2", "key3"]


def test_update_timestamp(manager: InMemoryRecordManager) -> None:
    """Test updating records in the database."""
    # no keys should be present in the set
    with patch.object(
        manager,
        "get_time",
        return_value=datetime(2021, 1, 2, tzinfo=timezone.utc).timestamp(),
// ... (220 more lines)

Subdomains

Dependencies

  • datetime
  • langchain_core.indexing
  • pytest
  • pytest_asyncio
  • unittest.mock

Frequently Asked Questions

What does test_in_memory_record_manager.py do?
test_in_memory_record_manager.py is a source file in the langchain codebase, written in python. It belongs to the CoreAbstractions domain, RunnableInterface subdomain.
What functions are defined in test_in_memory_record_manager.py?
test_in_memory_record_manager.py defines 11 function(s): amanager, manager, test_adelete_keys, test_aexists, test_aupdate, test_aupdate_timestamp, test_delete_keys, test_exists, test_list_keys, test_update, and 1 more.
What does test_in_memory_record_manager.py depend on?
test_in_memory_record_manager.py imports 5 module(s): datetime, langchain_core.indexing, pytest, pytest_asyncio, unittest.mock.
Where is test_in_memory_record_manager.py in the architecture?
test_in_memory_record_manager.py is located at libs/core/tests/unit_tests/indexing/test_in_memory_record_manager.py (domain: CoreAbstractions, subdomain: RunnableInterface, directory: libs/core/tests/unit_tests/indexing).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free