def test_create_pool_successfully(self, svc_authorize_mock,
                                   pool_create_mock,
                                   get_existing_pool_mock):
     set_module_args({
         'clustername': 'clustername',
         'domain': 'domain',
         'state': 'present',
         'username': '******',
         'password': '******',
         'name': 'ansible_pool',
         'datareduction': 'no',
         'easytier': 'auto',
         'encrypt': 'no',
         'ext': '1024',
     })
     pool = {
         u'message': u'Storage pool, id [0], '
         u'successfully created',
         u'id': u'0'
     }
     pool_create_mock.return_value = pool
     get_existing_pool_mock.return_value = []
     pool_created = IBMSVCmdiskgrp()
     with pytest.raises(AnsibleExitJson) as exc:
         pool_created.apply()
     self.assertTrue(exc.value.args[0]['changed'])
     get_existing_pool_mock.assert_called_with()
 def test_create_pool_but_pool_existed(self, svc_authorize_mock,
                                       pool_probe_mock,
                                       get_existing_pool_mock):
     set_module_args({
         'clustername': 'clustername',
         'domain': 'domain',
         'state': 'present',
         'username': '******',
         'password': '******',
         'name': 'ansible_pool',
     })
     pool_ret = [{
         "id": "0",
         "name": "Pool_Ansible_collections",
         "status": "online",
         "mdisk_count": "1",
         "vdisk_count": "1",
         "capacity": "5.23TB",
         "extent_size": "1024",
         "free_capacity": "5.23TB",
         "virtual_capacity": "4.00GB",
         "used_capacity": "4.00GB",
         "real_capacity": "4.00GB",
         "overallocation": "0",
         "warning": "0",
         "easy_tier": "on",
         "easy_tier_status": "balanced",
         "compression_active": "no",
         "compression_virtual_capacity": "0.00MB",
         "compression_compressed_capacity": "0.00MB",
         "compression_uncompressed_capacity": "0.00MB",
         "parent_mdisk_grp_id": "0",
         "parent_mdisk_grp_name": "Pool_Ansible_collections",
         "child_mdisk_grp_count": "0",
         "child_mdisk_grp_capacity": "0.00MB",
         "type": "parent",
         "encrypt": "no",
         "owner_type": "none",
         "owner_id": "",
         "owner_name": "",
         "site_id": "",
         "site_name": "",
         "data_reduction": "no",
         "used_capacity_before_reduction": "0.00MB",
         "used_capacity_after_reduction": "0.00MB",
         "overhead_capacity": "0.00MB",
         "deduplication_capacity_saving": "0.00MB",
         "reclaimable_capacity": "0.00MB",
         "easy_tier_fcm_over_allocation_max": "100%"
     }]
     get_existing_pool_mock.return_value = pool_ret
     pool_probe_mock.return_value = []
     pool_created = IBMSVCmdiskgrp()
     with pytest.raises(AnsibleExitJson) as exc:
         pool_created.apply()
     self.assertFalse(exc.value.args[0]['changed'])
     get_existing_pool_mock.assert_called_with()
 def test_pool_create_get_existing_pool_called(self, svc_authorize_mock,
                                               get_existing_pool_mock):
     set_module_args({
         'clustername': 'clustername',
         'domain': 'domain',
         'state': 'present',
         'username': '******',
         'password': '******',
         'name': 'test_pool_create_get_existing_pool_called',
     })
     pool_created = IBMSVCmdiskgrp()
     with pytest.raises(AnsibleExitJson) as exc:
         pool_created.apply()
     self.assertFalse(exc.value.args[0]['changed'])
     get_existing_pool_mock.assert_called_with()
 def test_create_pool_failed_since_missed_required_param(
         self, svc_authorize_mock, get_existing_pool_mock):
     set_module_args({
         'clustername': 'clustername',
         'domain': 'domain',
         'state': 'present',
         'username': '******',
         'password': '******',
         'name': 'ansible_pool',
     })
     get_existing_pool_mock.return_value = []
     pool_created = IBMSVCmdiskgrp()
     with pytest.raises(AnsibleFailJson) as exc:
         pool_created.apply()
     self.assertTrue(exc.value.args[0]['failed'])
     get_existing_pool_mock.assert_called_with()
 def test_delete_pool_but_pool_not_existed(self, svc_authorize_mock,
                                           get_existing_pool_mock):
     set_module_args({
         'clustername': 'clustername',
         'domain': 'domain',
         'state': 'absent',
         'username': '******',
         'password': '******',
         'name': 'ansible_pool',
         'datareduction': 'no',
         'easytier': 'auto',
         'encrypt': 'no',
         'ext': '1024',
     })
     get_existing_pool_mock.return_value = []
     pool_deleted = IBMSVCmdiskgrp()
     with pytest.raises(AnsibleExitJson) as exc:
         pool_deleted.apply()
     self.assertFalse(exc.value.args[0]['changed'])
     get_existing_pool_mock.assert_called_with()
 def test_create_pool_failed_since_no_message_in_result(
         self, svc_authorize_mock, svc_run_command_mock,
         get_existing_pool_mock):
     set_module_args({
         'clustername': 'clustername',
         'domain': 'domain',
         'state': 'present',
         'username': '******',
         'password': '******',
         'name': 'ansible_pool',
         'datareduction': 'no',
         'easytier': 'auto',
         'encrypt': 'no',
         'ext': '1024',
     })
     pool = {u'id': u'0'}
     svc_run_command_mock.return_value = pool
     get_existing_pool_mock.return_value = []
     pool_created = IBMSVCmdiskgrp()
     with pytest.raises(AnsibleFailJson) as exc:
         pool_created.apply()
     get_existing_pool_mock.assert_called_with()