Spaces:
Sleeping
Sleeping
Added HF test action
Browse files- .github/workflows/test.yml +25 -0
- tests/test_smoke.py +25 -0
.github/workflows/test.yml
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
name: Run chatbot test
|
| 2 |
+
|
| 3 |
+
on:
|
| 4 |
+
push:
|
| 5 |
+
pull_request:
|
| 6 |
+
|
| 7 |
+
jobs:
|
| 8 |
+
test:
|
| 9 |
+
runs-on: ubuntu-latest
|
| 10 |
+
|
| 11 |
+
steps:
|
| 12 |
+
- uses: actions/checkout@v4
|
| 13 |
+
|
| 14 |
+
- uses: actions/setup-python@v5
|
| 15 |
+
with:
|
| 16 |
+
python-version: "3.11"
|
| 17 |
+
|
| 18 |
+
- name: Install dependencies
|
| 19 |
+
run: |
|
| 20 |
+
pip install pytest gradio huggingface_hub
|
| 21 |
+
|
| 22 |
+
- name: Run pytest with HF token
|
| 23 |
+
env:
|
| 24 |
+
HF_TOKEN: ${{ secrets.HF_TOKEN }}
|
| 25 |
+
run: pytest -q
|
tests/test_smoke.py
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import sys, os
|
| 2 |
+
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
|
| 3 |
+
|
| 4 |
+
import app
|
| 5 |
+
|
| 6 |
+
class Token:
|
| 7 |
+
def __init__(self, token): self.token = token
|
| 8 |
+
|
| 9 |
+
def test_api_requires_token():
|
| 10 |
+
hf_token = os.environ.get("HF_TOKEN")
|
| 11 |
+
assert hf_token, "HF_TOKEN not set in environment"
|
| 12 |
+
|
| 13 |
+
gen = app.respond(
|
| 14 |
+
message="Hi",
|
| 15 |
+
history=[],
|
| 16 |
+
system_message="test",
|
| 17 |
+
max_tokens=8,
|
| 18 |
+
temperature=0.2,
|
| 19 |
+
top_p=0.9,
|
| 20 |
+
hf_token=Token(hf_token),
|
| 21 |
+
use_local_model=False,
|
| 22 |
+
)
|
| 23 |
+
first = next(gen)
|
| 24 |
+
assert "please log in" not in first.lower() # shouldn't get warning
|
| 25 |
+
assert isinstance(first, str)
|