mirror of https://github.com/arc53/DocsGPT
fix packaging and imports and introduce tests with pytest.
still issues with celery worker.pull/300/head
parent
9a393b4f74
commit
98a97f34f5
@ -0,0 +1,28 @@
|
||||
name: Run python tests with pytest
|
||||
|
||||
on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
python-version: ["3.9", "3.10", "3.11"]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Set up Python ${{ matrix.python-version }}
|
||||
uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: ${{ matrix.python-version }}
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
pip install pytest
|
||||
cd application
|
||||
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
|
||||
- name: Test with pytest
|
||||
run: |
|
||||
cd application
|
||||
pytest
|
@ -0,0 +1 @@
|
||||
|
@ -0,0 +1 @@
|
||||
|
@ -0,0 +1,37 @@
|
||||
from application.app import get_vectorstore
|
||||
|
||||
|
||||
# Test cases for get_vectorstore function
|
||||
def test_no_active_docs():
|
||||
data = {}
|
||||
assert get_vectorstore(data) == ""
|
||||
|
||||
|
||||
def test_default_active_docs():
|
||||
data = {"active_docs": "default"}
|
||||
assert get_vectorstore(data) == ""
|
||||
|
||||
|
||||
def test_local_default_active_docs():
|
||||
data = {"active_docs": "local/default"}
|
||||
assert get_vectorstore(data) == ""
|
||||
|
||||
|
||||
def test_local_custom_active_docs():
|
||||
data = {"active_docs": "local/custom_index"}
|
||||
assert get_vectorstore(data) == "indexes/local/custom_index"
|
||||
|
||||
|
||||
def test_remote_active_docs():
|
||||
data = {"active_docs": "remote_index"}
|
||||
assert get_vectorstore(data) == "vectors/remote_index"
|
||||
|
||||
|
||||
def test_active_docs_not_in_data():
|
||||
data = {"other_key": "value"}
|
||||
assert get_vectorstore(data) == ""
|
||||
|
||||
|
||||
def test_multiple_slashes_in_active_docs():
|
||||
data = {"active_docs": "local/some/other/index"}
|
||||
assert get_vectorstore(data) == "indexes/local/some/other/index"
|
@ -1,4 +1,4 @@
|
||||
from app import app
|
||||
from application.app import app
|
||||
|
||||
if __name__ == "__main__":
|
||||
app.run(debug=True, port=7091)
|
||||
|
Loading…
Reference in New Issue