Пример #1
0
 def test_main_exit_unexport_volumeset_from_hostset(
         self, mock_unexport_volumeset_from_hostset, mock_module,
         mock_client):
     """
     hpe3par vlun - success check
     """
     PARAMS_FOR_UNEXPORT = {
         'storage_system_ip': '192.168.0.1',
         'storage_system_name': '3PAR',
         'storage_system_username': '******',
         'storage_system_password': '******',
         'state': 'unexport_volumeset_from_hostset',
         'volume_name': 'test_vol_name',
         'volume_set_name': 'test_volset_name',
         'lunid': 12,
         'autolun': True,
         'host_name': 'test_host_name',
         'host_set_name': 'test_hostset_name',
         'node_val': 3,
         'slot': 2,
         'card_port': 1
     }
     # This creates a instance of the AnsibleModule mock.
     mock_module.params = PARAMS_FOR_UNEXPORT
     mock_module.return_value = mock_module
     instance = mock_module.return_value
     mock_unexport_volumeset_from_hostset.return_value = (
         True, True, "Deleted VLUN successfully.", {})
     vlun.main()
     # AnsibleModule.exit_json should be called
     instance.exit_json.assert_called_with(changed=True,
                                           msg="Deleted VLUN successfully.")
     # AnsibleModule.fail_json should not be called
     self.assertEqual(instance.fail_json.call_count, 0)
Пример #2
0
    def test_module_args(self, mock_module, mock_client):
        """
        hpe3par vlun - test module arguments
        """

        mock_module.params = self.PARAMS_FOR_PRESENT
        mock_module.return_value = mock_module
        vlun.main()
        mock_module.assert_called_with(argument_spec=self.fields)
Пример #3
0
 def test_main_exit_functionality_success_without_issue_attr_dict(
         self, mock_export_volume_to_host, mock_module, mock_client):
     """
     hpe3par vlun - success check
     """
     # This creates a instance of the AnsibleModule mock.
     mock_module.params = self.PARAMS_FOR_PRESENT
     mock_module.return_value = mock_module
     instance = mock_module.return_value
     mock_export_volume_to_host.return_value = (
         True, True, "Created VLUN successfully.", {})
     vlun.main()
     # AnsibleModule.exit_json should be called
     instance.exit_json.assert_called_with(changed=True,
                                           msg="Created VLUN successfully.")
     # AnsibleModule.fail_json should not be called
     self.assertEqual(instance.fail_json.call_count, 0)
Пример #4
0
    def test_main_exit_functionality_fail(self, mock_export_volume_to_host,
                                          mock_module, mock_client):
        """
        hpe3par vlun - exit fail check
        """
        # This creates a instance of the AnsibleModule mock.
        mock_module.params = self.PARAMS_FOR_PRESENT
        mock_module.return_value = mock_module
        instance = mock_module.return_value
        mock_export_volume_to_host.return_value = (False, False,
                                                   "VLUN creation failed", {
                                                       "dummy": "dummy"
                                                   })
        vlun.main()

        # AnsibleModule.exit_json should not be activated
        self.assertEqual(instance.exit_json.call_count, 0)
        # AnsibleModule.fail_json should be called
        instance.fail_json.assert_called_with(msg="VLUN creation failed")