f8d3cbdd59
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.
40 lines
1.2 KiB
Python
40 lines
1.2 KiB
Python
"""vSphere REST mapper unit tests."""
|
|
|
|
from app.vsphere.inventory import ManagedObject
|
|
from app.vsphere.rest import mappers
|
|
|
|
|
|
def test_vm_summary_maps_power_and_hardware() -> None:
|
|
obj = ManagedObject(
|
|
moid="vm-101",
|
|
type="VirtualMachine",
|
|
name="web-01",
|
|
parent_moid="group-v23",
|
|
props={"power_state": "POWERED_ON", "cpu_count": 2, "memory_size_mib": 4096},
|
|
)
|
|
summary = mappers.vm_summary(obj)
|
|
assert summary["vm"] == "vm-101"
|
|
assert summary["name"] == "web-01"
|
|
assert summary["power_state"] == "POWERED_ON"
|
|
assert summary["cpu_count"] == 2
|
|
assert summary["memory_size_MiB"] == 4096
|
|
|
|
|
|
def test_host_and_datastore_summaries() -> None:
|
|
host = ManagedObject(
|
|
moid="host-11",
|
|
type="HostSystem",
|
|
name="esxi01.lab.local",
|
|
parent_moid="domain-c21",
|
|
props={"connection_state": "CONNECTED", "power_state": "POWERED_ON"},
|
|
)
|
|
ds = ManagedObject(
|
|
moid="datastore-31",
|
|
type="Datastore",
|
|
name="datastore1",
|
|
parent_moid="group-s23",
|
|
props={"type": "VMFS", "capacity": 100, "free_space": 40},
|
|
)
|
|
assert mappers.host_summary(host)["host"] == "host-11"
|
|
assert mappers.datastore_summary(ds)["free_space"] == 40
|