Skip to main content

PyPI - Version Tests Coverage Status semantic-release: angular

Nanopublication Test Suite Connector

A Python connector that downloads and exposes the Nanopublication Test Suite contents for programmatic use.

This package provides a lightweight, zero-dependency API to fetch the official Nanopub Test Suite from GitHub (as a .tar.gz archive), extract it locally, and index test cases so other code can easily consume valid/invalid test nanopublications, transform test cases, and signing keys.


Table of contents


Installation

pip install nanopub-testsuite-connector

Or add it to your project's test dependencies:

pyproject.toml

[dependency-groups]
test = [
    "nanopub-testsuite-connector>=1.0.0",
]

Quick examples

Load the latest suite and list all valid PLAIN entries

from nanopub_testsuite_connector import NanopubTestSuite, TestSuiteSubfolder

suite = NanopubTestSuite.get_latest()
for entry in suite.get_valid(TestSuiteSubfolder.PLAIN):
    print(entry.name, "->", entry.path)

Load the testsuite at a specific commit

suite = NanopubTestSuite.get_at_commit("a1b2c3d")
print("Loaded testsuite version:", suite.version)

Look up an entry by artifact code or nanopub URI

suite = NanopubTestSuite.get_latest()

entry = suite.get_by_artifact_code("RA1sViVmXf-W2aZW4Qk74KTaiD9gpLBPe2LhMsinHKKz8")
print("Entry for artifact code:", entry.name)

entry = suite.get_by_nanopub_uri("http://purl.org/np/RAPPdsJKoVVp7KZTjdS3D2MvxfkNa-G4JDrnLjeMQFwnY")
print("Entry for URI:", entry.name)

Access transform cases for a named signing key

for tc in suite.get_transform_cases("rsa-key1"):
    print(tc.plain.name, "->", tc.signed.name, "| expected code:", tc.out_code)

Read a signing key pair

kp = suite.get_signing_key("rsa-key1")
print("Private key path:", kp.private_key)
print("Public key path: ", kp.public_key)

Use entries in pytest

import pytest
from nanopub_testsuite_connector import NanopubTestSuite, TestSuiteSubfolder


@pytest.fixture(scope="session")
def testsuite():
    return NanopubTestSuite.get_latest()


@pytest.mark.parametrize(
    "entry",
    NanopubTestSuite.get_latest().get_valid(TestSuiteSubfolder.PLAIN),
    ids=lambda e: e.name,
)
def test_valid_plain(entry):
    content = entry.read_text()
    assert "@prefix" in content

API overview

NanopubTestSuite

Method / property Description
NanopubTestSuite.get_latest() Download & load the main branch.
NanopubTestSuite.get_at_commit(sha) Download & load a specific commit SHA.
suite.version Git ref used when fetching this instance.
suite.root Path to the extracted temporary directory.
suite.get_valid() All valid TestSuiteEntry instances.
suite.get_valid(subfolder) Filter by PLAIN, SIGNED, or TRUSTY.
suite.get_invalid() All invalid TestSuiteEntry instances.
suite.get_invalid(subfolder) Filter by PLAIN, SIGNED, or TRUSTY.
suite.get_transform_cases() All TransformTestCase instances.
suite.get_transform_cases(key_name) Filter by signing key (e.g. "rsa-key1").
suite.get_signing_key(key_name) Returns a SigningKeyPair.
suite.get_by_artifact_code(code) Lookup by Trusty URI artifact code.
suite.get_by_nanopub_uri(uri) Lookup by full nanopub URI.
iter(suite) Iterate over all entries (valid + invalid).

TestSuiteEntry

Attribute Type Description
name str Filename (e.g. nanopub1.trig).
path Path Absolute path to the extracted file.
subfolder TestSuiteSubfolder PLAIN, SIGNED, or TRUSTY.
valid bool True if from valid/, False if from invalid/.
read_text() str Full file content as a string.
read_bytes() bytes Raw file bytes.

TestSuiteSubfolder

class TestSuiteSubfolder(str, Enum):
    PLAIN = "plain"
    SIGNED = "signed"
    TRUSTY = "trusty"

TransformTestCase

Attribute Type Description
key_name str Signing key used (e.g. rsa-key1).
plain TestSuiteEntry Input nanopub (from transform/plain).
signed TestSuiteEntry Expected output (from transform/signed/<key>).
out_code str | None Expected artifact code from *.out.code, or None.

SigningKeyPair

Attribute Type Description
name str Key directory name (e.g. rsa-key1).
private_key Path Path to the private key file.
public_key Path Path to the public key file.

Notes & troubleshooting

  • The connector downloads GitHub tarballs (archive/<ref>.tar.gz). An internet connection is required when fetching a new version or commit.
  • Downloaded data is extracted into a temporary directory created with tempfile.mkdtemp. The directory persists for the lifetime of your process. Clean it up manually via suite.root.parent if needed.
  • If extraction fails, ensure your environment allows outgoing HTTPS traffic.

License

MIT

Metadata

Release files for nanopub-testsuite-connector 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for nanopub-testsuite-connector 1.0.1
File Size Uploaded Provenance Actions
nanopub_testsuite_connector-1.0.1.tar.gz 90.2 kB Without provenance Details for nanopub_testsuite_connector-1.0.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for nanopub-testsuite-connector 1.0.1
File Interpreter ABI Platform Actions
nanopub_testsuite_connector-1.0.1-py3-none-any.whl Python 3 none any Details for nanopub_testsuite_connector-1.0.1-py3-none-any.whl

Total release size: 100.8 kB

Release files / nanopub_testsuite_connector-1.0.1.tar.gz

Download URL nanopub_testsuite_connector-1.0.1.tar.gz
Size 90.2 kB
Tags Source
SHA-256 checksum
How to use checksums
82f38f8f0b59e939c6413c74116f420a1268da71d32111994e15ee15a755650c
BLAKE2b-256 checksum
How to use checksums
a3f02725d30b4cc8b2e6112133be4d39021a3dea58c2629ea28c7b047d532c18
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.10 {"installer":{"name":"uv","version":"0.13.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / nanopub_testsuite_connector-1.0.1-py3-none-any.whl

Download URL nanopub_testsuite_connector-1.0.1-py3-none-any.whl
Size 10.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bff3380e059bc9dfee84539bd4ebffa3be6be9008351c2dacf5b1c1f179c594a
BLAKE2b-256 checksum
How to use checksums
361f72c9909f0c54ae0cff846cac7125e430ae485dad86814444c24d725db30d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.10 {"installer":{"name":"uv","version":"0.13.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for nanopub-testsuite-connector 1.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page