From 295cf0f9665dd315e4caa4f676ba0c30a6ee95ca Mon Sep 17 00:00:00 2001 From: Andreas Thalhammer Date: Wed, 30 Oct 2024 09:55:38 +0100 Subject: [PATCH 1/9] added first test cases --- requirements_dev.txt | 2 ++ test/__init__.py | 0 test/fasterid_test.py | 28 ++++++++++++++++++++++++++++ 3 files changed, 30 insertions(+) create mode 100644 requirements_dev.txt create mode 100644 test/__init__.py create mode 100644 test/fasterid_test.py diff --git a/requirements_dev.txt b/requirements_dev.txt new file mode 100644 index 0000000..acb0e5f --- /dev/null +++ b/requirements_dev.txt @@ -0,0 +1,2 @@ +httpx>=0.27.2 +rdflib>=7.1.1 \ No newline at end of file diff --git a/test/__init__.py b/test/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/test/fasterid_test.py b/test/fasterid_test.py new file mode 100644 index 0000000..69d238d --- /dev/null +++ b/test/fasterid_test.py @@ -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 \ No newline at end of file From 31237c36b579cd878243ed1ba1a68ef01186f41f Mon Sep 17 00:00:00 2001 From: Andreas Thalhammer Date: Fri, 8 Nov 2024 21:13:48 +0100 Subject: [PATCH 2/9] added workflow for tests --- .github/workflows/tests.yml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 .github/workflows/tests.yml diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..f87c2b4 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,21 @@ +name: fasterid + +on: [push] + +jobs: + build: + runs-on: alpine-latest + strategy: + matrix: + python-version: ["pypy3.10", "3.9", "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 + From 9929b18a83e79295ce114191b110a2596c92164d Mon Sep 17 00:00:00 2001 From: Andreas Thalhammer Date: Fri, 8 Nov 2024 21:19:42 +0100 Subject: [PATCH 3/9] update to ubuntu runner --- .github/workflows/tests.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index f87c2b4..fa4b495 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -4,10 +4,10 @@ on: [push] jobs: build: - runs-on: alpine-latest + runs-on: ubuntu-latest strategy: matrix: - python-version: ["pypy3.10", "3.9", "3.10", "3.11", "3.12", "3.13"] + python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"] steps: - uses: actions/checkout@v4 From c7d112cadb108dc0fb5f7117ac02f8d56b18741d Mon Sep 17 00:00:00 2001 From: Andreas Thalhammer Date: Fri, 8 Nov 2024 21:21:35 +0100 Subject: [PATCH 4/9] added pytest to requirements --- requirements_dev.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/requirements_dev.txt b/requirements_dev.txt index acb0e5f..c715de8 100644 --- a/requirements_dev.txt +++ b/requirements_dev.txt @@ -1,2 +1,3 @@ httpx>=0.27.2 -rdflib>=7.1.1 \ No newline at end of file +pytest>=8.3.3 +rdflib>=7.1.1 From f00f3831acac37787f088c35547d7830f9bd30f8 Mon Sep 17 00:00:00 2001 From: Andreas Thalhammer Date: Fri, 8 Nov 2024 21:22:52 +0100 Subject: [PATCH 5/9] removed support for 3.9 --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index fa4b495..572d78b 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -7,7 +7,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"] + python-version: ["3.10", "3.11", "3.12", "3.13"] steps: - uses: actions/checkout@v4 From 0695f167857c592916bd9937ac34c21ebed22902 Mon Sep 17 00:00:00 2001 From: Andreas Thalhammer Date: Fri, 8 Nov 2024 21:47:05 +0100 Subject: [PATCH 6/9] updating to 0.1.4 --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 8f6098d..ad44536 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,7 +3,7 @@ FROM python:3.12-alpine EXPOSE 80 RUN apk add wget -ARG FASTER_ID_VERSION="0.1.3" +ARG FASTER_ID_VERSION="0.1.4" RUN wget https://github.com/athalhammer/fasterid/archive/refs/tags/v${FASTER_ID_VERSION}.tar.gz RUN tar -xzf v${FASTER_ID_VERSION}.tar.gz From 53dbeef276d0307ca459a0f7cd0613f927c4210b Mon Sep 17 00:00:00 2001 From: Andreas Thalhammer Date: Fri, 8 Nov 2024 21:48:12 +0100 Subject: [PATCH 7/9] Revert "removed support for 3.9" This reverts commit f00f3831acac37787f088c35547d7830f9bd30f8. --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 572d78b..fa4b495 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -7,7 +7,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ["3.10", "3.11", "3.12", "3.13"] + python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"] steps: - uses: actions/checkout@v4 From 31df9b107fbb44dddc14428cf6c5f15654ee2567 Mon Sep 17 00:00:00 2001 From: Andreas Thalhammer Date: Fri, 8 Nov 2024 21:49:11 +0100 Subject: [PATCH 8/9] Revert "updating to 0.1.4" This reverts commit 0695f167857c592916bd9937ac34c21ebed22902. --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index ad44536..8f6098d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,7 +3,7 @@ FROM python:3.12-alpine EXPOSE 80 RUN apk add wget -ARG FASTER_ID_VERSION="0.1.4" +ARG FASTER_ID_VERSION="0.1.3" RUN wget https://github.com/athalhammer/fasterid/archive/refs/tags/v${FASTER_ID_VERSION}.tar.gz RUN tar -xzf v${FASTER_ID_VERSION}.tar.gz From 3ae3c7d8d2db3fd4708ddbaac37b36e0f62e94e4 Mon Sep 17 00:00:00 2001 From: Andreas Thalhammer Date: Fri, 8 Nov 2024 21:49:38 +0100 Subject: [PATCH 9/9] Reapply "updating to 0.1.4" This reverts commit 31df9b107fbb44dddc14428cf6c5f15654ee2567. --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 8f6098d..ad44536 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,7 +3,7 @@ FROM python:3.12-alpine EXPOSE 80 RUN apk add wget -ARG FASTER_ID_VERSION="0.1.3" +ARG FASTER_ID_VERSION="0.1.4" RUN wget https://github.com/athalhammer/fasterid/archive/refs/tags/v${FASTER_ID_VERSION}.tar.gz RUN tar -xzf v${FASTER_ID_VERSION}.tar.gz