-
Notifications
You must be signed in to change notification settings - Fork 123
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
56 additions
and
0 deletions.
There are no files selected for viewing
13 changes: 13 additions & 0 deletions
13
pagefind/integration_tests/python_api/background.toolproof.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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: >- | ||
<!DOCTYPE html><html lang="en"><head></head><body> <p | ||
data-url>Nothing</p></body></html> | ||
- step: I run 'python3 -m venv "$PWD/.venv"' | ||
- step: I run 'source "$PWD/.venv/bin/activate"' |
43 changes: 43 additions & 0 deletions
43
...tegration_tests/python_api/py-build-a-synthetic-index-to-memory-via-the-api.toolproof.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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="<html><body><h1>Testing, testing</h1></body></html>", | ||
source_path="dogs/index.html", | ||
) | ||
files = await index.get_files() | ||
for file in files: | ||
if "pagefind.js" in file["path"]: | ||
print(file["content"]) | ||
print(f"JS is at {file["path"]}") | ||
fragments = [file for file in files if "fragment" in file["path"]] | ||
print(f"{len(fragments)} fragment(s)") | ||
if __name__ == "__main__": | ||
asyncio.run(main()) | ||
- step: I run "PAGEFIND_BINARY_PATH=%pagefind_exec_path% python3 run.py" | ||
- step: stdout should contain "pagefind_version=" | ||
- step: stdout should contain "JS is at pagefind.js" | ||
- step: stdout should contain "1 fragment(s)" | ||
- step: I run "ls -lh public/pagefind/pagefind.js" and expect it to fail | ||
notes: "TODO: Build a file existence check into toolproof" |