Initial commit: VMware vSphere API simulator scaffold.
Add the FastAPI app, PostgreSQL migrations, Docker/Helm packaging, API contracts, docs, client examples, and the unit/integration/compatibility test suite for local client and tooling labs without a real vCenter.
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
"""Native vSphere console catalog tests."""
|
||||
|
||||
from app.vsphere.contracts.catalog import (
|
||||
list_vsphere_majors,
|
||||
vsphere_catalog_payload,
|
||||
vsphere_method_payload,
|
||||
)
|
||||
from app.vsphere.rest.coverage import catalog_entries, is_implemented
|
||||
|
||||
|
||||
def test_list_vsphere_majors() -> None:
|
||||
payload = list_vsphere_majors(runtime_version="8.0.2")
|
||||
series = {item["series"] for item in payload["majors"]}
|
||||
assert series == {
|
||||
"vSphere 7.0",
|
||||
"vSphere 7.0 U3",
|
||||
"vSphere 8.0",
|
||||
"vSphere 8.0 U2",
|
||||
}
|
||||
assert payload["plane"] == "vsphere-rest"
|
||||
|
||||
|
||||
def test_vsphere_catalog_marks_implemented_methods() -> None:
|
||||
payload = vsphere_catalog_payload(9)
|
||||
assert payload["source_version"] == "8.0.2"
|
||||
assert payload["method_count"] == len(catalog_entries())
|
||||
assert is_implemented("GET", "/api/vcenter/vm")
|
||||
assert is_implemented("POST", "/api/cis/tagging/category")
|
||||
assert vsphere_catalog_payload(6)["method_count"] < payload["method_count"]
|
||||
# Methods for the same path must be merged (GET+POST+DELETE on one path entry).
|
||||
vm_paths = [
|
||||
p for cat in payload["categories"] for p in cat["paths"] if p["path"] == "/api/vcenter/vm"
|
||||
]
|
||||
assert len(vm_paths) == 1
|
||||
assert {m["verb"] for m in vm_paths[0]["methods"]} >= {"GET", "POST"}
|
||||
|
||||
|
||||
def test_vsphere_method_payload_extracts_path_fields() -> None:
|
||||
payload = vsphere_method_payload(
|
||||
major=9,
|
||||
path="/api/vcenter/vm/{vm}",
|
||||
verb="GET",
|
||||
runtime_version="8.0.2",
|
||||
)
|
||||
assert payload["implemented"] is True
|
||||
assert len(payload["path_fields"]) == 1
|
||||
assert payload["path_fields"][0]["name"] == "vm"
|
||||
assert payload["resolved_path"] == "/api/vcenter/vm/vm-111"
|
||||
Reference in New Issue
Block a user