From 0d495b318588d86b1f235803435e6214cd4204df Mon Sep 17 00:00:00 2001 From: Liam Bigelow <40188355+bglw@users.noreply.github.com> Date: Mon, 30 Sep 2024 09:31:53 +1300 Subject: [PATCH] Add first Python API Toolproof test --- .../python_api/background.toolproof.yml | 13 ++++++ ...-index-to-memory-via-the-api.toolproof.yml | 43 +++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 pagefind/integration_tests/python_api/background.toolproof.yml create mode 100644 pagefind/integration_tests/python_api/py-build-a-synthetic-index-to-memory-via-the-api.toolproof.yml diff --git a/pagefind/integration_tests/python_api/background.toolproof.yml b/pagefind/integration_tests/python_api/background.toolproof.yml new file mode 100644 index 00000000..2331011b --- /dev/null +++ b/pagefind/integration_tests/python_api/background.toolproof.yml @@ -0,0 +1,13 @@ +# Requirements: +# venv +# python>=3.11 + +name: Python API Setup +type: reference +steps: + - step: I have a "public/index.html" file with the content {html} + html: >- +
Nothing
+ - step: I run 'python3 -m venv "$PWD/.venv"' + - step: I run 'source "$PWD/.venv/bin/activate"' diff --git a/pagefind/integration_tests/python_api/py-build-a-synthetic-index-to-memory-via-the-api.toolproof.yml b/pagefind/integration_tests/python_api/py-build-a-synthetic-index-to-memory-via-the-api.toolproof.yml new file mode 100644 index 00000000..45bc9441 --- /dev/null +++ b/pagefind/integration_tests/python_api/py-build-a-synthetic-index-to-memory-via-the-api.toolproof.yml @@ -0,0 +1,43 @@ +name: Python API > Build a synthetic index to memory via the api +platforms: + - linux + - mac + +steps: + - ref: ./background.toolproof.yml + - step: I have a "run.py" file with the content {python} + python: |2- + import sys + sys.path.append('%repo_wd%/wrappers/python/src') + + import asyncio + import json + import logging + import os + from pagefind.index import PagefindIndex, IndexConfig + + async def main(): + async with PagefindIndex() as index: + await index.add_html_file( + content="