-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
4 changed files
with
52 additions
and
0 deletions.
There are no files selected for viewing
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,21 @@ | ||
name: fasterid | ||
|
||
on: [push] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
python-version: ["3.10", "3.11", "3.12", "3.13"] | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- run: pip install -r requirements_dev.txt | ||
- run: pip install -r requirements.txt | ||
- run: pytest | ||
|
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,3 @@ | ||
httpx>=0.27.2 | ||
pytest>=8.3.3 | ||
rdflib>=7.1.1 |
Empty file.
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,28 @@ | ||
from fasterid import app | ||
from fastapi.testclient import TestClient | ||
from rdflib import Graph | ||
|
||
client = TestClient(app) | ||
|
||
def test_basic(): | ||
response = client.post("/") | ||
assert response.status_code == 201 | ||
assert isinstance(response.json(), dict) | ||
assert "@id" in response.json().keys() | ||
|
||
def test_multiple(): | ||
response = client.post("/", json={"number": 5}) | ||
assert response.status_code == 201 | ||
assert isinstance(response.json(), list) | ||
assert len(response.json()) == 5 | ||
|
||
def test_content_negotiation(): | ||
response = client.post("/", headers={'accept': 'application/ld+json'}) | ||
assert response.status_code == 201 | ||
assert response.headers["content-type"] == "application/ld+json" | ||
|
||
def test_json_ld(): | ||
response = client.post("/", json={"number": 5}, headers={'accept': 'application/ld+json'}) | ||
assert response.status_code == 201 | ||
g = Graph().parse(data=response.content, format="json-ld") | ||
assert len(g) == 5 |