Add unit test for overridden lc_namespace (#16093)

pull/16100/head
Nuno Campos 5 months ago committed by GitHub
parent 52114bdfac
commit 770f57196e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -30,10 +30,9 @@
"lc": 1,
"type": "constructor",
"id": [
"tests",
"unit_tests",
"load",
"test_dump",
"my",
"special",
"namespace",
"SpecialPerson"
],
"kwargs": {

@ -1,6 +1,6 @@
"""Test for Serializable base class"""
from typing import Any, Dict
from typing import Any, Dict, List
import pytest
from langchain_community.chat_models.openai import ChatOpenAI
@ -37,6 +37,10 @@ class SpecialPerson(Person):
another_visible: str = "bye"
@classmethod
def get_lc_namespace(cls) -> List[str]:
return ["my", "special", "namespace"]
# Gets merged with parent class's secrets
@property
def lc_secrets(self) -> Dict[str, str]:
@ -58,6 +62,7 @@ def test_person(snapshot: Any) -> None:
sp = SpecialPerson(another_secret="Wooo", secret="Hmm")
assert dumps(sp, pretty=True) == snapshot
assert Person.lc_id() == ["tests", "unit_tests", "load", "test_dump", "Person"]
assert SpecialPerson.lc_id() == ["my", "special", "namespace", "SpecialPerson"]
def test_typeerror() -> None:

Loading…
Cancel
Save