mirror of
https://github.com/khoj-ai/khoj.git
synced 2025-02-17 08:04:21 +00:00
Create pytest fixture to configure app with plugin, search types
This commit is contained in:
parent
f944408e69
commit
ab501a56c9
1 changed files with 14 additions and 0 deletions
|
@ -1,9 +1,12 @@
|
||||||
# External Packages
|
# External Packages
|
||||||
from copy import deepcopy
|
from copy import deepcopy
|
||||||
|
from fastapi.testclient import TestClient
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
# Internal Packages
|
# Internal Packages
|
||||||
|
from khoj.main import app
|
||||||
|
from khoj.configure import configure_routes, configure_search_types
|
||||||
from khoj.search_type import image_search, text_search
|
from khoj.search_type import image_search, text_search
|
||||||
from khoj.utils.helpers import resolve_absolute_path
|
from khoj.utils.helpers import resolve_absolute_path
|
||||||
from khoj.utils.rawconfig import (
|
from khoj.utils.rawconfig import (
|
||||||
|
@ -14,6 +17,7 @@ from khoj.utils.rawconfig import (
|
||||||
TextSearchConfig,
|
TextSearchConfig,
|
||||||
ImageSearchConfig,
|
ImageSearchConfig,
|
||||||
)
|
)
|
||||||
|
from khoj.utils import state
|
||||||
from khoj.processor.jsonl.jsonl_to_jsonl import JsonlToJsonl
|
from khoj.processor.jsonl.jsonl_to_jsonl import JsonlToJsonl
|
||||||
from khoj.processor.org_mode.org_to_jsonl import OrgToJsonl
|
from khoj.processor.org_mode.org_to_jsonl import OrgToJsonl
|
||||||
from khoj.search_filter.date_filter import DateFilter
|
from khoj.search_filter.date_filter import DateFilter
|
||||||
|
@ -89,6 +93,16 @@ def content_config(tmp_path_factory, search_config: SearchConfig):
|
||||||
return content_config
|
return content_config
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture(scope="session")
|
||||||
|
def client(content_config: ContentConfig, search_config: SearchConfig):
|
||||||
|
state.config.content_type = content_config
|
||||||
|
state.config.search_type = search_config
|
||||||
|
state.SearchType = configure_search_types(state.config)
|
||||||
|
|
||||||
|
configure_routes(app)
|
||||||
|
return TestClient(app)
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(scope="function")
|
@pytest.fixture(scope="function")
|
||||||
def new_org_file(content_config: ContentConfig):
|
def new_org_file(content_config: ContentConfig):
|
||||||
# Setup
|
# Setup
|
||||||
|
|
Loading…
Add table
Reference in a new issue