SPB Git

spb/ai-atlas

Public
4.5 KB · 73 lines python
1import pytest23from aiatlas.connectors.code.github import GitHubConnector, repo_entries4from aiatlas.connectors.code.pypi import PyPIConnector, _license, _norm5from aiatlas.registry import organizations6from aiatlas.sdk.facts import Target7from tests.conftest import claims_of, extract_from_fixture, fixture_path8910def test_repositories_registry():11    entries = repo_entries()12    assert len(entries) >= 70 and len({e["key"] for e in entries}) == len(entries)13    assert all(e["kind"] in {"framework", "runtime", "library", "agent", "tool", "model"} and e["repo"].count("/") == 1 for e in entries)14    assert all(e["organization"] in organizations() for e in entries if e.get("organization"))151617@pytest.fixture18def gh() -> GitHubConnector:19    return GitHubConnector()202122async def test_github_discover(gh):23    targets = await gh.discover(None)  # type: ignore[arg-type]24    assert len(targets) == 3 * len(repo_entries())25    assert {t.doc_type for t in targets} == {"repository", "feed", "readme"} and gh.rate_per_min == 20262728async def test_github_repo_page(gh):29    target = Target(url="https://github.com/vllm-project/vllm", doc_type="repository", key="repo:vllm-project/vllm", meta={"repo": "vllm-project/vllm"})30    facts = await extract_from_fixture(gh, target, fixture_path("github", "repo-vllm.html"))31    vllm = next(e for e in facts.entities if e.entity_type == "framework")32    assert vllm.identifiers == {"github_repo": "vllm-project/vllm", "pypi": "vllm"} and vllm.organization.name == "vLLM project"33    c = claims_of(facts, "vllm")34    assert c["metric.stars"] == 91512 and c["metric.forks"] == 22070 and c["license"] == "Apache-2.0" and c["metric.releases"] == 10535    assert c["description"].startswith("A high-throughput") and c["homepage"] == "https://vllm.ai" and "llm-serving" in c["topics"]36    assert c["created_at"] == "2023-02-09T11:23:20+00:00" and "language" not in c            # language bar is client-rendered373839async def test_github_releases(gh):40    target = Target(url="https://github.com/vllm-project/vllm/releases.atom", doc_type="feed", key="releases:vllm-project/vllm", meta={"repo": "vllm-project/vllm"})41    facts = await extract_from_fixture(gh, target, fixture_path("github", "releases-vllm.atom"), content_type="application/atom+xml")42    c = claims_of(facts, "vllm")43    assert c["latest_version"] == "0.29.0" and c["latest_release_tag"] == "v0.29.0" and c["latest_release_at"].startswith("2026-09-10")44    events = [e for e in facts.events if e.event_type == "RELEASE"]45    assert len(events) == 10 and events[0].dedupe_key == "RELEASE:https://github.com/vllm-project/vllm/releases/tag/proto-v0.1.0"46    assert all(e.effective_at is not None for e in events)474849async def test_github_readme(gh):50    target = Target(url="https://raw.githubusercontent.com/vllm-project/vllm/HEAD/README.md", doc_type="readme", key="readme:vllm-project/vllm", meta={"repo": "vllm-project/vllm"})51    facts = await extract_from_fixture(gh, target, fixture_path("github", "readme-vllm.md"), content_type="text/markdown")52    assert facts.document_entity is not None and facts.document_entity.identifiers["github_repo"] == "vllm-project/vllm"535455async def test_pypi_package():56    c = PyPIConnector()57    assert len(c.packages()) >= 100 and "vllm" in c.packages() and c.packages()["vllm"]["repo"] == "vllm-project/vllm"58    target = Target(url="https://pypi.org/pypi/vllm/json", doc_type="package", key="pkg:vllm", meta={"pypi": "vllm"})59    facts = await extract_from_fixture(c, target, fixture_path("pypi", "vllm.json"), content_type="application/json")60    ent = next(e for e in facts.entities if e.entity_type == "framework")61    assert ent.identifiers == {"github_repo": "vllm-project/vllm", "pypi": "vllm"}       # merges with the GitHub entity62    cl = claims_of(facts, "vllm")63    assert cl["pypi_version"] == "0.29.0" and cl["pypi_release_at"] == "2026-09-09T08:58:32+00:00" and cl["pypi_license"] == "Apache-2.0"64    assert "license" not in cl and "homepage" not in cl                                 # owned by the GitHub page for mapped repos65    assert cl["requires_python"] == "<3.15,>=3.10" and cl["metric.releases"] == 97 and cl["docs_url"] == "https://docs.vllm.ai/en/latest/"66    assert "latest_version" not in cl                                                     # owned by the GitHub release feed for mapped repos676869def test_pypi_helpers():70    assert _norm("Llama_CPP.python") == "llama-cpp-python"71    assert _license({"license_expression": "MIT"}) == "MIT"72    assert _license({"license": "", "classifiers": ["License :: OSI Approved :: Apache Software License"]}) == "Apache Software License"73
Files · 2e6e573fcb38a29b1d64a8ec87767f3c274b471c
Menu

Theme