From 0ce992e22e7258611bce5e0a4ece4f6cf7ed1274 Mon Sep 17 00:00:00 2001 From: Itay Date: Sun, 28 Jan 2024 22:59:51 +0200 Subject: [PATCH] CI: Run Python tests (#1001) --- .github/workflows/pr-python-tests.yml | 35 +++++++++++++++++++ .../cross_connector_utils/test_html_utils.py | 4 ++- 2 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/pr-python-tests.yml diff --git a/.github/workflows/pr-python-tests.yml b/.github/workflows/pr-python-tests.yml new file mode 100644 index 000000000..beb890a35 --- /dev/null +++ b/.github/workflows/pr-python-tests.yml @@ -0,0 +1,35 @@ +name: Python Unit Tests + +on: + pull_request: + branches: [ main ] + +jobs: + backend-check: + runs-on: ubuntu-latest + + env: + PYTHONPATH: ./backend + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.11' + cache: 'pip' + cache-dependency-path: | + backend/requirements/default.txt + backend/requirements/dev.txt + + - name: Install Dependencies + run: | + python -m pip install --upgrade pip + pip install -r backend/requirements/default.txt + pip install -r backend/requirements/dev.txt + + - name: Run Tests + shell: script -q -e -c "bash --noprofile --norc -eo pipefail {0}" + run: py.test -o junit_family=xunit2 -xv --ff backend/tests/unit diff --git a/backend/tests/unit/danswer/connectors/cross_connector_utils/test_html_utils.py b/backend/tests/unit/danswer/connectors/cross_connector_utils/test_html_utils.py index 571f818a2..8c502269d 100644 --- a/backend/tests/unit/danswer/connectors/cross_connector_utils/test_html_utils.py +++ b/backend/tests/unit/danswer/connectors/cross_connector_utils/test_html_utils.py @@ -1,3 +1,4 @@ +import pathlib import unittest from danswer.connectors.cross_connector_utils.html_utils import parse_html_page_basic @@ -5,7 +6,8 @@ from danswer.connectors.cross_connector_utils.html_utils import parse_html_page_ class TestQAPostprocessing(unittest.TestCase): def test_parse_table(self) -> None: - with open("./test_table.html", "r") as file: + dir_path = pathlib.Path(__file__).parent.resolve() + with open(f"{dir_path}/test_table.html", "r") as file: content = file.read() parsed = parse_html_page_basic(content)