|
13 | 13 | virt_network_config = {'network_name': 'test'} |
14 | 14 | install_Settings = {'vm_ip': '00.00.00.00', 'nim_ip': '00.00.00.00'} |
15 | 15 | vnic_config = {'vnic_adapter_id': 0, 'backing_devices': 'bd'} |
| 16 | +update_config = {'new_vm_name': 'test'} |
16 | 17 | test_data = [ |
17 | 18 | # ALL Create partition testdata |
18 | 19 | # system name is missing |
|
57 | 58 | # unsupported parameter os_type,proc,mem |
58 | 59 | ({'hmc_host': "0.0.0.0", 'hmc_auth': hmc_auth, 'state': 'absent', |
59 | 60 | 'system_name': "systemname", 'vm_name': 'vmname', 'proc': '4', 'mem': |
60 | | - '1024', 'os_type': 'aix_linux', 'new_name': None, 'proc_unit': '4', 'prof_name': 'default', 'keylock': 'manual', 'iIPLsource': 'a', |
| 61 | + '1024', 'os_type': 'aix_linux', 'proc_unit': '4', 'prof_name': 'default', 'keylock': 'manual', 'iIPLsource': 'a', |
61 | 62 | 'volume_config': volume_config, 'virt_network_config': virt_network_config, 'all_resources': True, 'max_virtual_slots': 25, 'advanced_info': True, |
62 | 63 | 'min_proc': '1', 'max_proc': '2', 'min_proc_unit': '0.1', 'max_proc_unit': '1', 'proc_mode': 'uncapped', 'weight': '124', |
63 | 64 | 'proc_compatibility_mode': 'POWER8', 'shared_proc_pool': '1', 'min_mem': '2048', 'max_mem': '1024', 'vm_id': 4, 'install_settings': install_Settings, |
|
99 | 100 | ({'hmc_host': None, 'hmc_auth': hmc_auth, 'state': None, 'action': 'poweron', |
100 | 101 | 'system_name': "systemname", 'vm_name': "vm_name"}, "ParameterError: mandatory parameter 'hmc_host' is missing"), |
101 | 102 | # hmc_auth is missing |
102 | | - ({'hmc_host': "0.0.0.0", 'hmc_auth': None, 'state': None, 'action': 'poweron', |
| 103 | + ({'hmc_host': "0.0.0.0", 'hmc_auth': None, 'state': None, 'action': 'poweron', 'update_config': None, |
103 | 104 | 'system_name': "systemname", 'vm_name': "vmname"}, "ParameterError: mandatory parameter 'hmc_auth' is missing"), |
104 | 105 | # unsupported parameter os_type,proc,mem |
105 | 106 | ({'hmc_host': "0.0.0.0", 'hmc_auth': hmc_auth, 'state': None, 'action': 'poweron', |
|
112 | 113 | "ParameterError: unsupported parameters: proc, mem, os_type, proc_unit, volume_config, virt_network_config, retain_vios_cfg, delete_vdisks," |
113 | 114 | " all_resources, max_virtual_slots, advanced_info, min_proc, max_proc, min_proc_unit, max_proc_unit, proc_mode, weight, proc_compatibility_mode," |
114 | 115 | " shared_proc_pool, min_mem, max_mem, vm_id, install_settings, vnic_config, shutdown_option, restart_option")] |
| 116 | +test_data4 = [ |
| 117 | + # ALL modify partition testdata |
| 118 | + # vmname is missing |
| 119 | + ({'hmc_host': "0.0.0.0", 'hmc_auth': hmc_auth, 'state': None, 'action': 'modify_vm', |
| 120 | + 'system_name': "systemname", 'vm_name': None, 'update_config': update_config}, "ParameterError: mandatory parameter 'vm_name' is missing"), |
| 121 | + # update config is missing |
| 122 | + ({'hmc_host': "0.0.0.0", 'hmc_auth': hmc_auth, 'state': None, 'action': 'modify_vm', |
| 123 | + 'system_name': "systemname", 'vm_name': 'vm_name', 'update_config': None}, "ParameterError: mandatory parameter 'update_config' is missing"), |
| 124 | + # system name is missing |
| 125 | + ({'hmc_host': "0.0.0.0", 'hmc_auth': hmc_auth, 'state': None, 'action': 'modify_vm', |
| 126 | + 'system_name': None, 'vm_name': 'vm_name', 'update_config': update_config}, "ParameterError: mandatory parameter 'system_name' is missing"), |
| 127 | + # hmc host is missing |
| 128 | + ({'hmc_host': None, 'hmc_auth': hmc_auth, 'state': None, 'action': 'modify_vm', |
| 129 | + 'system_name': 'systemname', 'vm_name': 'vm_name', 'update_config': update_config}, "ParameterError: mandatory parameter 'hmc_host' is missing"), |
| 130 | + # hmc_auth is missing |
| 131 | + ({'hmc_host': '0.0.0.0', 'hmc_auth': None, 'state': None, 'action': 'modify_vm', |
| 132 | + 'system_name': 'systemname', 'vm_name': 'vm_name', 'update_config': update_config}, "ParameterError: mandatory parameter 'hmc_auth' is missing")] |
115 | 133 |
|
116 | 134 |
|
117 | 135 | def common_mock_setup(mocker): |
@@ -163,3 +181,14 @@ def test_call_inside_powervm_poweron_partition(mocker, powervm_test_input, expec |
163 | 181 | assert expectedError == repr(e.value) |
164 | 182 | else: |
165 | 183 | hmc_powervm.poweron_partition(hmc_powervm, powervm_test_input) |
| 184 | + |
| 185 | + |
| 186 | +@pytest.mark.parametrize("powervm_test_input, expectedError", test_data3) |
| 187 | +def test_call_inside_powervm_poweron_partition(mocker, powervm_test_input, expectedError): |
| 188 | + hmc_powervm = common_mock_setup(mocker) |
| 189 | + if 'ParameterError' in expectedError: |
| 190 | + with pytest.raises(ParameterError) as e: |
| 191 | + hmc_powervm.rename_partition(hmc_powervm, powervm_test_input) |
| 192 | + assert expectedError == repr(e.value) |
| 193 | + else: |
| 194 | + hmc_powervm.rename_partition(hmc_powervm, powervm_test_input) |
0 commit comments