add vm_id in result output

This commit is contained in:
mayabi 2025-03-30 13:47:31 +03:30
parent 1e4efeea01
commit aa1b757c3d
2 changed files with 37 additions and 37 deletions

View file

@ -171,9 +171,7 @@ class TestProxmoxBackupScheduleModule(ModuleTestCase):
RESOURCE_LIST
)
self.connect_mock.return_value.cluster.backup.get.side_effect = (
lambda backup_id=None: BACKUP_JOBS if backup_id is None else [
job for job in BACKUP_JOBS if job['id'] == backup_id
]
lambda backup_id=None: BACKUP_JOBS if backup_id is None else [job for job in BACKUP_JOBS if job['id'] == backup_id]
)
def tearDown(self):
@ -189,35 +187,36 @@ class TestProxmoxBackupScheduleModule(ModuleTestCase):
assert result["msg"] == "missing required arguments: api_host, api_user, state"
def test_update_vmid_in_backup(self):
with patch('builtins.input', return_value='mocked input'):
with pytest.raises(AnsibleExitJson) as exc_info:
set_module_args({
'api_host': 'proxmoxhost',
'api_user': 'root@pam',
'api_password': 'supersecret',
'vm_name': 'test05',
'backup_id': 'backup-001',
'state': 'present'
})
self.module.main()
with pytest.raises(AnsibleExitJson) as exc_info:
set_module_args({
'api_host': 'proxmoxhost',
'api_user': 'root@pam',
'api_password': 'supersecret',
'vm_name': 'test05',
'backup_id': 'backup-001',
'state': 'present'
})
self.module.main()
result = exc_info.value.args[0]
assert result['changed'] is True
result = exc_info.value.args[0]
assert result['changed'] is True
assert result['vm_id'] == 105
def test_delete_vmid_from_backup(self):
with patch('builtins.input', return_value='mocked input'):
with pytest.raises(AnsibleExitJson) as exc_info:
set_module_args({
'api_host': 'proxmoxhost',
'api_user': 'root@pam',
'api_password': 'supersecret',
'vm_id': '101',
'state': 'absent'
})
self.module.main()
with pytest.raises(AnsibleExitJson) as exc_info:
set_module_args({
'api_host': 'proxmoxhost',
'api_user': 'root@pam',
'api_password': 'supersecret',
'vm_id': 101,
'state': 'absent'
})
self.module.main()
result = exc_info.value.args[0]
assert result['changed'] is True
result = exc_info.value.args[0]
assert result['changed'] is True
assert result['vm_id'] == 101
if __name__ == '__main__':