1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2026-02-04 07:51:50 +00:00

fix ruff case B007 (#11115)

* fix ruff case B007

* rollback inventory/iocage

* re-do the fix in inventory/iocage

* add cases in tests/unit/plugins

* rollback plugins/module_utils/memset.py

* rollback extraneous changes in plugins/modules/xcc_redfish_command.py

* add changelog frag
This commit is contained in:
Alexei Znamensky 2025-11-13 09:06:14 +13:00 committed by GitHub
parent 40aea793ee
commit 58bb1e7c04
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
32 changed files with 90 additions and 73 deletions

View file

@ -0,0 +1,28 @@
minor_changes:
- elastic callback plugin - fix cases of unused variables in loops (https://github.com/ansible-collections/community.general/pull/11115).
- opentelemetry callback plugin - fix cases of unused variables in loops (https://github.com/ansible-collections/community.general/pull/11115).
- wsl connection plugin - fix cases of unused variables in loops (https://github.com/ansible-collections/community.general/pull/11115).
- cobbler inventory plugin - fix cases of unused variables in loops (https://github.com/ansible-collections/community.general/pull/11115).
- iocage inventory plugin - fix cases of unused variables in loops (https://github.com/ansible-collections/community.general/pull/11115).
- _stormssh module utils - fix cases of unused variables in loops (https://github.com/ansible-collections/community.general/pull/11115).
- keycloak module utils - fix cases of unused variables in loops (https://github.com/ansible-collections/community.general/pull/11115).
- redfish_utils module utils - fix cases of unused variables in loops (https://github.com/ansible-collections/community.general/pull/11115).
- ali_instance - fix cases of unused variables in loops (https://github.com/ansible-collections/community.general/pull/11115).
- apt_rpm - fix cases of unused variables in loops (https://github.com/ansible-collections/community.general/pull/11115).
- dnf_config_manager - fix cases of unused variables in loops (https://github.com/ansible-collections/community.general/pull/11115).
- haproxy - fix cases of unused variables in loops (https://github.com/ansible-collections/community.general/pull/11115).
- hpilo_info - fix cases of unused variables in loops (https://github.com/ansible-collections/community.general/pull/11115).
- hwc_ecs_instance - fix cases of unused variables in loops (https://github.com/ansible-collections/community.general/pull/11115).
- hwc_vpc_port - fix cases of unused variables in loops (https://github.com/ansible-collections/community.general/pull/11115).
- influxdb_user - fix cases of unused variables in loops (https://github.com/ansible-collections/community.general/pull/11115).
- keycloak_authentication - fix cases of unused variables in loops (https://github.com/ansible-collections/community.general/pull/11115).
- keycloak_client_rolemapping - fix cases of unused variables in loops (https://github.com/ansible-collections/community.general/pull/11115).
- keycloak_component - fix cases of unused variables in loops (https://github.com/ansible-collections/community.general/pull/11115).
- keycloak_realm_key - fix cases of unused variables in loops (https://github.com/ansible-collections/community.general/pull/11115).
- keycloak_realm_rolemapping - fix cases of unused variables in loops (https://github.com/ansible-collections/community.general/pull/11115).
- keycloak_user_rolemapping - fix cases of unused variables in loops (https://github.com/ansible-collections/community.general/pull/11115).
- keycloak_userprofile - fix cases of unused variables in loops (https://github.com/ansible-collections/community.general/pull/11115).
- nmcli - fix cases of unused variables in loops (https://github.com/ansible-collections/community.general/pull/11115).
- pear - fix cases of unused variables in loops (https://github.com/ansible-collections/community.general/pull/11115).
- xbps - fix cases of unused variables in loops (https://github.com/ansible-collections/community.general/pull/11115).
- xcc_redfish_command - fix cases of unused variables in loops (https://github.com/ansible-collections/community.general/pull/11115).

View file

@ -201,7 +201,7 @@ class ElasticSource:
tasks = [] tasks = []
parent_start_time = None parent_start_time = None
for task_uuid, task in tasks_data.items(): for task in tasks_data.values():
if parent_start_time is None: if parent_start_time is None:
parent_start_time = task.start parent_start_time = task.start
tasks.append(task) tasks.append(task)
@ -224,7 +224,7 @@ class ElasticSource:
label(ansible_host_ip=self.ip_address) label(ansible_host_ip=self.ip_address)
for task_data in tasks: for task_data in tasks:
for host_uuid, host_data in task_data.host_data.items(): for host_data in task_data.host_data.values():
self.create_span_data(apm_cli, task_data, host_data) self.create_span_data(apm_cli, task_data, host_data)
apm_cli.end_transaction(name=__name__, result=status, duration=end_time - parent_start_time) apm_cli.end_transaction(name=__name__, result=status, duration=end_time - parent_start_time)

View file

@ -272,7 +272,7 @@ class OpenTelemetrySource:
tasks = [] tasks = []
parent_start_time = None parent_start_time = None
for task_uuid, task in tasks_data.items(): for task in tasks_data.values():
if parent_start_time is None: if parent_start_time is None:
parent_start_time = task.start parent_start_time = task.start
tasks.append(task) tasks.append(task)
@ -309,7 +309,7 @@ class OpenTelemetrySource:
parent.set_attribute("ansible.host.ip", self.ip_address) parent.set_attribute("ansible.host.ip", self.ip_address)
parent.set_attribute("ansible.host.user", self.user) parent.set_attribute("ansible.host.user", self.user)
for task in tasks: for task in tasks:
for host_uuid, host_data in task.host_data.items(): for host_data in task.host_data.values():
with tracer.start_as_current_span(task.name, start_time=task.start, end_on_exit=False) as span: with tracer.start_as_current_span(task.name, start_time=task.start, end_on_exit=False) as span:
self.update_span_data(task, host_data, span, disable_logs, disable_attributes_in_logs) self.update_span_data(task, host_data, span, disable_logs, disable_attributes_in_logs)

View file

@ -541,8 +541,8 @@ class Connection(ConnectionBase):
return self return self
def _any_keys_added(self) -> bool: def _any_keys_added(self) -> bool:
for hostname, keys in self.ssh._host_keys.items(): # type: ignore[attr-defined] # TODO: figure out what _host_keys is! for host_keys in self.ssh._host_keys.values(): # type: ignore[attr-defined] # TODO: figure out what _host_keys is!
for keytype, key in keys.items(): for key in host_keys.values():
added_this_time = getattr(key, "_added_by_ansible_this_time", False) added_this_time = getattr(key, "_added_by_ansible_this_time", False)
if added_this_time: if added_this_time:
return True return True

View file

@ -373,7 +373,7 @@ class InventoryModule(BaseInventoryPlugin, Cacheable):
ip_address_first = None ip_address_first = None
ipv6_address = None ipv6_address = None
ipv6_address_first = None ipv6_address_first = None
for iname, ivalue in interfaces.items(): for ivalue in interfaces.values():
# Set to first interface or management interface if defined or hostname matches dns_name # Set to first interface or management interface if defined or hostname matches dns_name
if ivalue["ip_address"] != "": if ivalue["ip_address"] != "":
if ip_address_first is None: if ip_address_first is None:

View file

@ -292,7 +292,7 @@ class InventoryModule(BaseInventoryPlugin, Constructable, Cacheable):
self.get_jails(t_stdout, results) self.get_jails(t_stdout, results)
if get_properties: if get_properties:
for hostname, host_vars in results["_meta"]["hostvars"].items(): for hostname in results["_meta"]["hostvars"]:
cmd_get_properties = cmd.copy() cmd_get_properties = cmd.copy()
cmd_get_properties.append(self.IOCAGE) cmd_get_properties.append(self.IOCAGE)
cmd_get_properties.append("get") cmd_get_properties.append("get")
@ -335,7 +335,7 @@ class InventoryModule(BaseInventoryPlugin, Constructable, Cacheable):
except Exception as e: except Exception as e:
raise AnsibleError(f"Failed to get pool: {e}") from e raise AnsibleError(f"Failed to get pool: {e}") from e
for hostname, host_vars in results["_meta"]["hostvars"].items(): for hostname in results["_meta"]["hostvars"]:
iocage_hooks = [] iocage_hooks = []
for hook in hooks_results: for hook in hooks_results:
path = f"/{iocage_pool}/iocage/jails/{hostname}/root{hook}" path = f"/{iocage_pool}/iocage/jails/{hostname}/root{hook}"

View file

@ -184,7 +184,7 @@ class ConfigParser:
continue continue
searchable_information = host_entry.get("host") searchable_information = host_entry.get("host")
for key, value in host_entry.get("options").items(): for value in host_entry.get("options").values():
if isinstance(value, list): if isinstance(value, list):
value = " ".join(value) value = " ".join(value)
if isinstance(value, int): if isinstance(value, int):

View file

@ -2350,7 +2350,7 @@ class KeycloakAPI:
""" """
try: try:
if diff > 0: if diff > 0:
for i in range(diff): for _i in range(diff):
self._request( self._request(
URL_AUTHENTICATION_EXECUTION_RAISE_PRIORITY.format( URL_AUTHENTICATION_EXECUTION_RAISE_PRIORITY.format(
url=self.baseurl, realm=realm, id=executionId url=self.baseurl, realm=realm, id=executionId
@ -2358,7 +2358,7 @@ class KeycloakAPI:
method="POST", method="POST",
) )
elif diff < 0: elif diff < 0:
for i in range(-diff): for _i in range(-diff):
self._request( self._request(
URL_AUTHENTICATION_EXECUTION_LOWER_PRIORITY.format( URL_AUTHENTICATION_EXECUTION_LOWER_PRIORITY.format(
url=self.baseurl, realm=realm, id=executionId url=self.baseurl, realm=realm, id=executionId

View file

@ -2913,7 +2913,7 @@ class RedfishUtils:
@staticmethod @staticmethod
def _virt_media_image_inserted(resources, image_url): def _virt_media_image_inserted(resources, image_url):
for uri, data in resources.items(): for data in resources.values():
if data.get("Image"): if data.get("Image"):
if urlparse(image_url) == urlparse(data.get("Image")): if urlparse(image_url) == urlparse(data.get("Image")):
if data.get("Inserted", False) and data.get("ImageName"): if data.get("Inserted", False) and data.get("ImageName"):

View file

@ -890,7 +890,7 @@ def main():
if state == "present": if state == "present":
if not instance_ids: if not instance_ids:
if len(instances) > count: if len(instances) > count:
for i in range(0, len(instances) - count): for _i in range(0, len(instances) - count):
inst = instances[len(instances) - 1] inst = instances[len(instances) - 1]
if inst.status != "stopped" and not force: if inst.status != "stopped" and not force:
module.fail_json( module.fail_json(

View file

@ -215,7 +215,7 @@ def update_package_db(module):
def dir_size(module, path): def dir_size(module, path):
total_size = 0 total_size = 0
for cur_path, dirs, files in os.walk(path): for cur_path, _dirs, files in os.walk(path):
for f in files: for f in files:
total_size += os.path.getsize(os.path.join(cur_path, f)) total_size += os.path.getsize(os.path.join(cur_path, f))
return total_size return total_size

View file

@ -133,7 +133,7 @@ def get_repo_states(module):
repos = dict() repos = dict()
last_repo = "" last_repo = ""
for i, line in enumerate(out.split("\n")): for line in out.split("\n"):
m = REPO_ID_RE.match(line) m = REPO_ID_RE.match(line)
if m: if m:
if len(last_repo) > 0: if len(last_repo) > 0:

View file

@ -359,7 +359,7 @@ class HAProxy:
the expected status in that time, the module will fail. If the service was the expected status in that time, the module will fail. If the service was
not found, the module will fail. not found, the module will fail.
""" """
for i in range(1, self.wait_retries): for _i in range(1, self.wait_retries):
state = self.get_state_for(pxname, svname) state = self.get_state_for(pxname, svname)
# We can assume there will only be 1 element in state because both svname and pxname are always set when we get here # We can assume there will only be 1 element in state because both svname and pxname are always set when we get here

View file

@ -234,7 +234,7 @@ def main():
if memory_details_summary: if memory_details_summary:
info["hw_memory_details_summary"] = memory_details_summary info["hw_memory_details_summary"] = memory_details_summary
info["hw_memory_total"] = 0 info["hw_memory_total"] = 0
for cpu, details in memory_details_summary.items(): for details in memory_details_summary.values():
cpu_total_memory_size = details.get("total_memory_size") cpu_total_memory_size = details.get("total_memory_size")
if cpu_total_memory_size: if cpu_total_memory_size:
ram = re.search(r"(\d+)\s+(\w+)", cpu_total_memory_size) ram = re.search(r"(\d+)\s+(\w+)", cpu_total_memory_size)

View file

@ -1174,16 +1174,14 @@ def expand_delete_servers(d, array_index):
req = [] req = []
n = 1 transformed = dict()
for i in range(n):
transformed = dict()
v = expand_delete_servers_id(d, new_ai) v = expand_delete_servers_id(d, new_ai)
if not is_empty_value(v): if not is_empty_value(v):
transformed["id"] = v transformed["id"] = v
if transformed: if transformed:
req.append(transformed) req.append(transformed)
return req return req

View file

@ -509,16 +509,14 @@ def expand_create_fixed_ips(d, array_index):
req = [] req = []
n = 1 transformed = dict()
for i in range(n):
transformed = dict()
v = navigate_value(d, ["ip_address"], new_array_index) v = navigate_value(d, ["ip_address"], new_array_index)
if not is_empty_value(v): if not is_empty_value(v):
transformed["ip_address"] = v transformed["ip_address"] = v
if transformed: if transformed:
req.append(transformed) req.append(transformed)
return req return req
@ -1011,17 +1009,15 @@ def expand_list_fixed_ips(d, array_index):
req = [] req = []
n = 1 transformed = dict()
for i in range(n):
transformed = dict()
v = navigate_value(d, ["ip_address"], new_array_index) v = navigate_value(d, ["ip_address"], new_array_index)
transformed["ip_address"] = v transformed["ip_address"] = v
for v in transformed.values(): for v in transformed.values():
if v is not None: if v is not None:
req.append(transformed) req.append(transformed)
break break
return req if req else None return req if req else None

View file

@ -175,7 +175,7 @@ def set_user_grants(module, client, user_name, grants):
try: try:
parsed_grants = [] parsed_grants = []
# Fix privileges wording # Fix privileges wording
for i, v in enumerate(current_grants): for v in current_grants:
if v["privilege"] != "NO PRIVILEGES": if v["privilege"] != "NO PRIVILEGES":
if v["privilege"] == "ALL PRIVILEGES": if v["privilege"] == "ALL PRIVILEGES":
v["privilege"] = "ALL" v["privilege"] = "ALL"

View file

@ -289,7 +289,7 @@ def create_or_update_executions(kc, config, realm="master"):
if exec_index != -1: if exec_index != -1:
# Remove key that doesn't need to be compared with existing_exec # Remove key that doesn't need to be compared with existing_exec
exclude_key = ["flowAlias", "subFlowType"] exclude_key = ["flowAlias", "subFlowType"]
for index_key, key in enumerate(new_exec, start=0): for key in new_exec:
if new_exec[key] is None: if new_exec[key] is None:
exclude_key.append(key) exclude_key.append(key)
# Compare the executions to see if it need changes # Compare the executions to see if it need changes

View file

@ -326,7 +326,7 @@ def main():
if roles is None: if roles is None:
module.exit_json(msg="Nothing to do (no roles specified).") module.exit_json(msg="Nothing to do (no roles specified).")
else: else:
for role_index, role in enumerate(roles, start=0): for role in roles:
if role["name"] is None and role["id"] is None: if role["name"] is None and role["id"] is None:
module.fail_json(msg="Either the `name` or `id` has to be specified on each role.") module.fail_json(msg="Either the `name` or `id` has to be specified on each role.")
# Fetch missing role_id # Fetch missing role_id
@ -350,7 +350,7 @@ def main():
result["proposed"] = list(assigned_roles_before) if assigned_roles_before else [] result["proposed"] = list(assigned_roles_before) if assigned_roles_before else []
update_roles = [] update_roles = []
for role_index, role in enumerate(roles, start=0): for role in roles:
# Fetch roles to assign if state present # Fetch roles to assign if state present
if state == "present": if state == "present":
for available_role in available_roles_before: for available_role in available_roles_before:

View file

@ -254,7 +254,7 @@ def main():
changeset_copy["id"] = component_id changeset_copy["id"] = component_id
# Compare top-level parameters # Compare top-level parameters
for param, value in changeset.items(): for param in changeset:
before_component[param] = component[param] before_component[param] = component[param]
if changeset_copy[param] != component[param] and param != "config": if changeset_copy[param] != component[param] and param != "config":
@ -266,8 +266,8 @@ def main():
before_component["config"][p] = component["config"][p] or [] before_component["config"][p] = component["config"][p] or []
except KeyError: except KeyError:
before_component["config"][p] = [] before_component["config"][p] = []
if changeset_copy["config"][p] != component["config"][p]: if v != component["config"][p]:
changes += f"config.{p}: {component['config'][p]} -> {changeset_copy['config'][p]}, " changes += f"config.{p}: {component['config'][p]} -> {v}, "
result["changed"] = True result["changed"] = True
# Check all the possible states of the resource and do what is needed to # Check all the possible states of the resource and do what is needed to

View file

@ -392,7 +392,7 @@ def main():
changeset_copy["id"] = key_id changeset_copy["id"] = key_id
# Compare top-level parameters # Compare top-level parameters
for param, value in changeset.items(): for param in changeset:
before_realm_key[param] = key[param] before_realm_key[param] = key[param]
if changeset_copy[param] != key[param] and param != "config": if changeset_copy[param] != key[param] and param != "config":
@ -402,8 +402,8 @@ def main():
# Compare parameters under the "config" key # Compare parameters under the "config" key
for p, v in changeset_copy["config"].items(): for p, v in changeset_copy["config"].items():
before_realm_key["config"][p] = key["config"][p] before_realm_key["config"][p] = key["config"][p]
if changeset_copy["config"][p] != key["config"][p]: if v != key["config"][p]:
changes += f"config.{p}: {key['config'][p]} -> {changeset_copy['config'][p]}, " changes += f"config.{p}: {key['config'][p]} -> {v}, "
result["changed"] = True result["changed"] = True
# Sanitize linefeeds for the privateKey. Without this the JSON payload # Sanitize linefeeds for the privateKey. Without this the JSON payload

View file

@ -304,7 +304,7 @@ def main():
if roles is None: if roles is None:
module.exit_json(msg="Nothing to do (no roles specified).") module.exit_json(msg="Nothing to do (no roles specified).")
else: else:
for role_index, role in enumerate(roles, start=0): for role in roles:
if role["name"] is None and role["id"] is None: if role["name"] is None and role["id"] is None:
module.fail_json(msg="Either the `name` or `id` has to be specified on each role.") module.fail_json(msg="Either the `name` or `id` has to be specified on each role.")
# Fetch missing role_id # Fetch missing role_id
@ -330,7 +330,7 @@ def main():
result["proposed"] = list(assigned_roles_before) if assigned_roles_before else [] result["proposed"] = list(assigned_roles_before) if assigned_roles_before else []
update_roles = [] update_roles = []
for role_index, role in enumerate(roles, start=0): for role in roles:
# Fetch roles to assign if state present # Fetch roles to assign if state present
if state == "present": if state == "present":
if any(assigned == role["name"] for assigned in assigned_roles_before): if any(assigned == role["name"] for assigned in assigned_roles_before):

View file

@ -333,7 +333,7 @@ def main():
if roles is None: if roles is None:
module.exit_json(msg="Nothing to do (no roles specified).") module.exit_json(msg="Nothing to do (no roles specified).")
else: else:
for role_index, role in enumerate(roles, start=0): for role in roles:
if role.get("name") is None and role.get("id") is None: if role.get("name") is None and role.get("id") is None:
module.fail_json(msg="Either the `name` or `id` has to be specified on each role.") module.fail_json(msg="Either the `name` or `id` has to be specified on each role.")
# Fetch missing role_id # Fetch missing role_id
@ -373,7 +373,7 @@ def main():
result["proposed"] = roles result["proposed"] = roles
update_roles = [] update_roles = []
for role_index, role in enumerate(roles, start=0): for role in roles:
# Fetch roles to assign if state present # Fetch roles to assign if state present
if state == "present": if state == "present":
for available_role in available_roles_before: for available_role in available_roles_before:

View file

@ -664,7 +664,7 @@ def main():
) )
# Compare top-level parameters # Compare top-level parameters
for param, value in changeset.items(): for param in changeset:
before_realm_userprofile[param] = userprofile[param] before_realm_userprofile[param] = userprofile[param]
if changeset_copy[param] != userprofile[param] and param != "config": if changeset_copy[param] != userprofile[param] and param != "config":
@ -674,8 +674,8 @@ def main():
# Compare parameters under the "config" userprofile # Compare parameters under the "config" userprofile
for p, v in changeset_copy["config"].items(): for p, v in changeset_copy["config"].items():
before_realm_userprofile["config"][p] = userprofile["config"][p] before_realm_userprofile["config"][p] = userprofile["config"][p]
if changeset_copy["config"][p] != userprofile["config"][p]: if v != userprofile["config"][p]:
changes += f"config.{p}: {userprofile['config'][p]} -> {changeset_copy['config'][p]}, " changes += f"config.{p}: {userprofile['config'][p]} -> {v}, "
result["changed"] = True result["changed"] = True
# Check all the possible states of the resource and do what is needed to # Check all the possible states of the resource and do what is needed to

View file

@ -2553,7 +2553,7 @@ class Nmcli:
supported_properties = self.get_supported_properties(setting) supported_properties = self.get_supported_properties(setting)
unsupported_properties = [] unsupported_properties = []
for property, value in getattr(self, setting_key).items(): for property in getattr(self, setting_key):
if property not in supported_properties: if property not in supported_properties:
unsupported_properties.append(property) unsupported_properties.append(property)

View file

@ -311,10 +311,6 @@ def main():
if p["name"]: if p["name"]:
pkgs = p["name"].split(",") pkgs = p["name"].split(",")
pkg_files = []
for i, pkg in enumerate(pkgs):
pkg_files.append(None)
if module.check_mode: if module.check_mode:
check_packages(module, pkgs, p["state"]) check_packages(module, pkgs, p["state"])

View file

@ -286,7 +286,7 @@ def remove_packages(module, xbps_path, packages):
def install_packages(module, xbps_path, state, packages): def install_packages(module, xbps_path, state, packages):
"""Returns true if package install succeeds.""" """Returns true if package install succeeds."""
toInstall = [] toInstall = []
for i, package in enumerate(packages): for package in packages:
"""If the package is installed and state == present or state == latest """If the package is installed and state == present or state == latest
and is up-to-date then skip""" and is up-to-date then skip"""
installed, updated = query_package(module, xbps_path, package) installed, updated = query_package(module, xbps_path, package)

View file

@ -418,7 +418,7 @@ class XCCRedfishUtils(RedfishUtils):
# eject all inserted media one by one # eject all inserted media one by one
ejected_media_list = [] ejected_media_list = []
for uri, data in resources.items(): for data in resources.values():
if data.get("Image") and data.get("Inserted", True): if data.get("Image") and data.get("Inserted", True):
returndict = self.virtual_media_eject_one(data.get("Image")) returndict = self.virtual_media_eject_one(data.get("Image"))
if not returndict["ret"]: if not returndict["ret"]:

View file

@ -28,7 +28,6 @@ ignore = [
"UP030", # Use implicit references for positional format fields "UP030", # Use implicit references for positional format fields
"UP031", # Use format specifiers instead of percent format "UP031", # Use format specifiers instead of percent format
"UP041", # Replace aliased errors with `TimeoutError` "UP041", # Replace aliased errors with `TimeoutError`
"B007", # unused-loop-control-variable
"B015", # useless-comparison "B015", # useless-comparison
"B026", # star-arg-unpacking-after-keyword-arg "B026", # star-arg-unpacking-after-keyword-arg
"B904", # raise-without-from-inside-except "B904", # raise-without-from-inside-except

View file

@ -91,7 +91,7 @@ def test_get_jails(inventory):
def test_get_properties(inventory): def test_get_properties(inventory):
results = {"_meta": {"hostvars": {}}} results = {"_meta": {"hostvars": {}}}
inventory.get_jails(inventory.jails, results) inventory.get_jails(inventory.jails, results)
for hostname, host_vars in results["_meta"]["hostvars"].items(): for hostname in results["_meta"]["hostvars"]:
inventory.get_properties(inventory.prpts[hostname], results, hostname) inventory.get_properties(inventory.prpts[hostname], results, hostname)
assert results == inventory.ps_ok assert results == inventory.ps_ok
@ -99,7 +99,7 @@ def test_get_properties(inventory):
def test_populate(inventory, mocker): def test_populate(inventory, mocker):
results = {"_meta": {"hostvars": {}}} results = {"_meta": {"hostvars": {}}}
inventory.get_jails(inventory.jails, results) inventory.get_jails(inventory.jails, results)
for hostname, host_vars in results["_meta"]["hostvars"].items(): for hostname in results["_meta"]["hostvars"]:
inventory.get_properties(inventory.prpts[hostname], results, hostname) inventory.get_properties(inventory.prpts[hostname], results, hostname)
inventory.get_option = mocker.MagicMock(side_effect=get_option) inventory.get_option = mocker.MagicMock(side_effect=get_option)
inventory.populate(results) inventory.populate(results)

View file

@ -145,7 +145,7 @@ def test_invalid_csv(data, dialect, dialect_params, fieldnames):
result = False result = False
try: try:
for row in reader: for _row in reader:
continue continue
except csv.CSVError: except csv.CSVError:
result = True result = True

View file

@ -96,9 +96,9 @@ class TestPritunlOrg(ModuleTestCase):
# except for changed which should be false the second time # except for changed which should be false the second time
for k, v in idempotent_exc.items(): for k, v in idempotent_exc.items():
if k == "changed": if k == "changed":
self.assertFalse(idempotent_exc[k]) self.assertFalse(v)
else: else:
self.assertEqual(create_exc[k], idempotent_exc[k]) self.assertEqual(create_exc[k], v)
def test_absent(self): def test_absent(self):
"""Test organization removal from Pritunl.""" """Test organization removal from Pritunl."""