27 lines
869 B
Python
27 lines
869 B
Python
from pve_vm_setup.services.factory import ProxmoxServiceFactory
|
|
from pve_vm_setup.services.fake import FakeProxmoxService
|
|
from pve_vm_setup.services.proxmox import LiveProxmoxService
|
|
from pve_vm_setup.settings import AppSettings
|
|
|
|
|
|
def test_factory_returns_fake_service_when_live_env_is_missing() -> None:
|
|
settings = AppSettings.from_env({}, load_dotenv_file=False)
|
|
|
|
service = ProxmoxServiceFactory.create(settings)
|
|
|
|
assert isinstance(service, FakeProxmoxService)
|
|
|
|
|
|
def test_factory_returns_live_service_when_live_env_is_present() -> None:
|
|
settings = AppSettings.from_env(
|
|
{
|
|
"PROXMOX_URL": "https://proxmox.example.invalid:8006",
|
|
},
|
|
load_dotenv_file=False,
|
|
)
|
|
|
|
service = ProxmoxServiceFactory.create(settings)
|
|
try:
|
|
assert isinstance(service, LiveProxmoxService)
|
|
finally:
|
|
service.close()
|