Skip to content

Commit 0d08d8e

Browse files
shixishclaude
andcommitted
ci: live tests on push to main, workflow_dispatch, cron 17 14 1,15 * *
Separate workflow, never on pull requests, concurrency of 1. Adds a cheap live DQL POST/entities suite asserting on shape only. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
1 parent 92fc982 commit 0d08d8e

2 files changed

Lines changed: 79 additions & 0 deletions

File tree

‎.github/workflows/live-tests.yml‎

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Live tests
2+
3+
# Real-API tests (`pytest -m live`). Deliberately never run on pull requests,
4+
# so a fork or PR can neither spend credits nor reach the secret.
5+
on:
6+
push:
7+
branches: [main]
8+
workflow_dispatch:
9+
schedule:
10+
- cron: "17 14 1,15 * *"
11+
12+
permissions:
13+
contents: read
14+
15+
jobs:
16+
live:
17+
if: github.event_name != 'pull_request'
18+
runs-on: ubuntu-latest
19+
concurrency:
20+
group: live-tests
21+
cancel-in-progress: false
22+
env:
23+
DIFFBOT_TOKEN: ${{ secrets.DIFFBOT_TOKEN }}
24+
# The SDK's own credential lookup reads DIFFBOT_API_TOKEN.
25+
DIFFBOT_API_TOKEN: ${{ secrets.DIFFBOT_TOKEN }}
26+
steps:
27+
- uses: actions/checkout@v4
28+
29+
- name: Install uv
30+
uses: astral-sh/setup-uv@v5
31+
with:
32+
python-version: "3.12"
33+
34+
- name: Install dependencies (locked)
35+
run: uv sync --frozen --extra dev
36+
37+
- name: Run live tests
38+
run: uv run pytest -m live -v

‎tests/test_live.py‎

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
"""Cheap live checks against the real API (``pytest -m live``).
2+
3+
Skipped by default. Assertions are on response *shape* only, never web content.
4+
Never include token values in assertion messages.
5+
"""
6+
import pytest
7+
8+
pytestmark = pytest.mark.live
9+
10+
11+
def test_live_dql_post_hit_count(db):
12+
result = db.dql("type:Organization name:Diffbot", size=0)
13+
assert isinstance(result, dict)
14+
assert "hits" in result
15+
16+
17+
def test_live_dql_post_single_read(db):
18+
result = db.dql('type:Organization name:"Diffbot"', size=1)
19+
assert len(result["data"]) == 1
20+
21+
22+
def test_live_dql_post_csv(db):
23+
body = db.dql('type:Organization name:"Diffbot"', size=1, format="csv", raw=True)
24+
assert isinstance(body, bytes) and len(body) > 0
25+
26+
27+
def test_live_dql_post_jsonl(db):
28+
body = db.dql('type:Organization name:"Diffbot"', size=1, format="jsonl", raw=True)
29+
assert isinstance(body, bytes) and len(body) > 0
30+
31+
32+
def test_live_dql_long_query_beyond_url_limit(db):
33+
query = "type:Organization or(" + ",".join(f'name:"Acme Widgets {i}"' for i in range(600)) + ")"
34+
assert len(query) > 8192
35+
result = db.dql(query, size=0)
36+
assert "hits" in result
37+
38+
39+
def test_live_entities(db):
40+
result = db.entities("Diffbot is a company based in Menlo Park.")
41+
assert "entities" in result

0 commit comments

Comments
 (0)