def test_module_fail_when_required_args_missing(self, mock_create_sf_connection): ''' required arguments are reported as errors ''' with pytest.raises(AnsibleFailJson) as exc: set_module_args({}) my_module() print('Info: %s' % exc.value.args[0]['msg'])
def test_delete_initiators(self, mock_create_sf_connection): ''' test if delete initiator is called ''' module_args = {} module_args.update(self.set_default_args()) initiator_dict = {"state": "absent", "initiators": [{"name": "a"}]} module_args.update(initiator_dict) set_module_args(module_args) mock_create_sf_connection.return_value = MockSFConnection() my_obj = my_module() with pytest.raises(AnsibleExitJson) as exc: my_obj.apply() print('Info: test_delete_initiators: %s' % repr(exc.value)) assert exc.value.args[0]['changed']