code: import pytest
  
  from langchain_community.vectorstores import LanceDB
  from tests.integration_tests.vectorstores.fake_embeddings import FakeEmbeddings
  
  
  @pytest.mark.requires("lancedb")
  def test_lancedb_with_connection() -> None:
      import lancedb
  
      embeddings = FakeEmbeddings()
      db = lancedb.connect("/tmp/lancedb")
      texts = ["text 1", "text 2", "item 3"]
      vectors = embeddings.embed_documents(texts)
      table = db.create_table(
          "my_table",
          data=[
              {"vector": vectors[idx], "id": text, "text": text}
              for idx, text in enumerate(texts)
          ],
          mode="overwrite",
      )
      store = LanceDB(table, embeddings)
      result = store.similarity_search("text 1")
      result_texts = [doc.page_content for doc in result]
      assert "text 1" in result_texts
  
  
  @pytest.mark.requires("lancedb")
  def test_lancedb_without_connection() -> None:
      embeddings = FakeEmbeddings()
      texts = ["text 1", "text 2", "item 3"]
  
      store = LanceDB(embedding=embeddings)
      store.add_texts(texts)
      result = store.similarity_search("text 1")
      result_texts = [doc.page_content for doc in result]
      assert "text 1" in result_texts
  
  
  @pytest.mark.requires("lancedb")
  def test_lancedb_add_texts() -> None:
      embeddings = FakeEmbeddings()
  
      store = LanceDB(embedding=embeddings)
      store.add_texts(["text 2"])
      result = store.similarity_search("text 2")
      result_texts = [doc.page_content for doc in result]
      assert "text 2" in result_texts
  
apis: lancedb.connect
extract_api: [((151, 182), 'pytest.mark.requires', 'pytest.mark.requires', (['"""lancedb"""'], {}), "('lancedb')\n", (171, 182), False, 'import pytest\n'), ((810, 841), 'pytest.mark.requires', 'pytest.mark.requires', (['"""lancedb"""'], {}), "('lancedb')\n", (830, 841), False, 'import pytest\n'), ((1178, 1209), 'pytest.mark.requires', 'pytest.mark.requires', (['"""lancedb"""'], {}), "('lancedb')\n", (1198, 1209), False, 'import pytest\n'), ((264, 280), 'tests.integration_tests.vectorstores.fake_embeddings.FakeEmbeddings', 'FakeEmbeddings', ([], {}), '()\n', (278, 280), False, 'from tests.integration_tests.vectorstores.fake_embeddings import FakeEmbeddings\n'), ((290, 321), 'lancedb.connect', 'lancedb.connect', (['"""/tmp/lancedb"""'], {}), "('/tmp/lancedb')\n", (305, 321), False, 'import lancedb\n'), ((641, 667), 'langchain_community.vectorstores.LanceDB', 'LanceDB', (['table', 'embeddings'], {}), '(table, embeddings)\n', (648, 667), False, 'from langchain_community.vectorstores import LanceDB\n'), ((906, 922), 'tests.integration_tests.vectorstores.fake_embeddings.FakeEmbeddings', 'FakeEmbeddings', ([], {}), '()\n', (920, 922), False, 'from tests.integration_tests.vectorstores.fake_embeddings import FakeEmbeddings\n'), ((979, 1008), 'langchain_community.vectorstores.LanceDB', 'LanceDB', ([], {'embedding': 'embeddings'}), '(embedding=embeddings)\n', (986, 1008), False, 'from langchain_community.vectorstores import LanceDB\n'), ((1265, 1281), 'tests.integration_tests.vectorstores.fake_embeddings.FakeEmbeddings', 'FakeEmbeddings', ([], {}), '()\n', (1279, 1281), False, 'from tests.integration_tests.vectorstores.fake_embeddings import FakeEmbeddings\n'), ((1295, 1324), 'langchain_community.vectorstores.LanceDB', 'LanceDB', ([], {'embedding': 'embeddings'}), '(embedding=embeddings)\n', (1302, 1324), False, 'from langchain_community.vectorstores import LanceDB\n')]