Initial working version
This commit is contained in:
parent
34a0627e76
commit
b6886cb34a
61 changed files with 4475 additions and 6 deletions
30
tests/test_factory.py
Normal file
30
tests/test_factory.py
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
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",
|
||||
"PROXMOX_USER": "root",
|
||||
"PROXMOX_PASSWORD": "secret",
|
||||
"PROXMOX_REALM": "pam",
|
||||
},
|
||||
load_dotenv_file=False,
|
||||
)
|
||||
|
||||
service = ProxmoxServiceFactory.create(settings)
|
||||
try:
|
||||
assert isinstance(service, LiveProxmoxService)
|
||||
finally:
|
||||
service.close()
|
||||
Loading…
Add table
Add a link
Reference in a new issue