Ejemplo n.º 1
0
 def test_main_exit_stop(self, mock_stop_clone, mock_module, mock_client):
     """
     hpe3par offline clone - success check
     """
     PARAMS_FOR_RESYNC = {
         'storage_system_ip': '192.168.0.1',
         'storage_system_name': '3PAR',
         'storage_system_username': '******',
         'storage_system_password': '******',
         'clone_name': 'test_clone',
         'base_volume_name': 'base_volume',
         'dest_cpg': None,
         'save_snapshot': None,
         'priority': None,
         'skip_zero': None,
         'state': 'stop'
     }
     # This creates a instance of the AnsibleModule mock.
     mock_module.params = PARAMS_FOR_RESYNC
     mock_module.return_value = mock_module
     instance = mock_module.return_value
     mock_stop_clone.return_value = (True, True,
                                     "Stopped Offline clone successfully.",
                                     {})
     hpe3par_offline_clone.main()
     # AnsibleModule.exit_json should be called
     instance.exit_json.assert_called_with(
         changed=True, msg="Stopped Offline clone successfully.")
     # AnsibleModule.fail_json should not be called
     self.assertEqual(instance.fail_json.call_count, 0)
Ejemplo n.º 2
0
    def test_module_args(self, mock_module, mock_client):
        """
        hpe3par offline clone - test module arguments
        """
        PARAMS_FOR_PRESENT = {
            'storage_system_ip': '192.168.0.1',
            'storage_system_username': '******',
            'storage_system_password': '******',
            'clone_name': 'test_clone',
            'base_volume_name': 'base_volume',
            'dest_cpg': 'dest_cpg',
            'save_snapshot': False,
            'priority': 'MEDIUM',
            'skip_zero': False,
            'state': 'present'
        }

        mock_module.params = PARAMS_FOR_PRESENT
        mock_module.return_value = mock_module
        hpe3par_offline_clone.main()
        mock_module.assert_called_with(argument_spec=self.fields)