Skip to content

Commit

Permalink
Unit tests for LiteralDataLayer.
Browse files Browse the repository at this point in the history
  • Loading branch information
dokterbob committed Sep 27, 2024
1 parent bcac555 commit bf8ccab
Show file tree
Hide file tree
Showing 4 changed files with 815 additions and 11 deletions.
15 changes: 9 additions & 6 deletions backend/tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import datetime
from contextlib import asynccontextmanager
from unittest.mock import AsyncMock, Mock

Expand All @@ -10,10 +11,12 @@


@pytest.fixture
def mock_persisted_user():
mock = Mock(spec=PersistedUser)
mock.id = "test_user_id"
return mock
def persisted_test_user():
return PersistedUser(
id="test_user_id",
createdAt=datetime.datetime.now().isoformat(),
identifier="test_user_identifier",
)


@pytest.fixture
Expand Down Expand Up @@ -44,8 +47,8 @@ async def create_chainlit_context(mock_session):


@pytest_asyncio.fixture
async def mock_chainlit_context(mock_persisted_user, mock_session):
mock_session.user = mock_persisted_user
async def mock_chainlit_context(persisted_test_user, mock_session):
mock_session.user = persisted_test_user
return create_chainlit_context(mock_session)


Expand Down
6 changes: 6 additions & 0 deletions backend/tests/data/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from unittest.mock import AsyncMock

from chainlit.data.base import BaseStorageClient
from chainlit.user import User


@pytest.fixture
Expand All @@ -13,3 +14,8 @@ def mock_storage_client():
"object_key": "test_user/test_element/test.txt",
}
return mock_client


@pytest.fixture
def test_user() -> User:
return User(identifier="test_user_identifier", metadata={})
Loading

0 comments on commit bf8ccab

Please sign in to comment.