def test_ensure_get_called_valid_capacity_pool(self, client_f, mock_base): set_module_args(self.set_default_args()) mock_base.return_value = Mock() client_f.return_value = Mock() my_obj = capacity_pool_module() my_obj.netapp_client.pools = self.netapp_client.pools assert my_obj.get_azure_netapp_capacity_pool() is not None
def test_ensure_get_called_non_existing_capacity_pool( self, client_f, mock_base): data = self.set_default_args() data['name'] = 'invalid' set_module_args(data) mock_base.return_value = Mock() client_f.return_value = Mock() my_obj = capacity_pool_module() my_obj.netapp_client.pools = self.netapp_client.pools assert my_obj.get_azure_netapp_capacity_pool() is None
def test_ensure_delete_called(self, client_f, mock_delete, mock_get, mock_base): data = self.set_default_args() data['state'] = 'absent' set_module_args(data) mock_base.return_value = Mock() mock_get.return_value = Mock() my_obj = capacity_pool_module() my_obj.netapp_client.pools = self.netapp_client.pools with pytest.raises(AnsibleExitJson) as exc: my_obj.exec_module() assert exc.value.args[0]['changed'] mock_delete.assert_called_with()
def test_ensure_modify_called(self, client_f, mock_modify, mock_get, mock_base): data = self.set_default_args() data['name'] = 'create' data['size'] = 3 set_module_args(data) mock_get.return_value = None mock_base.return_value = Mock() client_f.return_value = Mock() my_obj = capacity_pool_module() my_obj.netapp_client.pools = self.netapp_client.pools with pytest.raises(AnsibleExitJson) as exc: my_obj.exec_module() assert exc.value.args[0]['changed'] mock_modify.assert_called_with()
def test_module_fail_when_required_args_missing(self): ''' required arguments are reported as errors ''' with pytest.raises(AnsibleFailJson) as exc: set_module_args({}) capacity_pool_module() print('Info: %s' % exc.value.args[0]['msg'])