Skip to content

Fix Sanity and UT execution#308

Merged
JkhatriInfobox merged 7 commits intoinfobloxopen:masterfrom
sarya-infoblox:Tests
Dec 16, 2025
Merged

Fix Sanity and UT execution#308
JkhatriInfobox merged 7 commits intoinfobloxopen:masterfrom
sarya-infoblox:Tests

Conversation

@sarya-infoblox
Copy link
Contributor

Unit and Sanity Tests are fixed

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request modernizes the codebase by removing dependencies on the deprecated six library and migrating to native Python 3 syntax. The changes also update the CI/CD workflow to properly handle testing across different Ansible versions.

Key changes:

  • Replaced all iteritems() calls from six library with native Python 3 .items() method across multiple modules
  • Updated safe_eval import from ansible.module_utils.common.validation to use ast.literal_eval directly
  • Enhanced GitHub Actions workflow to support testing with Ansible devel branch using Python 3.12 and added specific handling for coverage versions

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
plugins/modules/nios_range.py Removed six.iteritems import and replaced usage with native .items() method
plugins/modules/nios_network.py Removed six.iteritems import and replaced all usages with .items() method
plugins/modules/nios_host_record.py Removed six.iteritems import and replaced usage with .items() method
plugins/modules/nios_fixed_address.py Removed six.iteritems import and replaced all usages with .items() method
plugins/modules/nios_dtc_topology.py Removed six.iteritems import and replaced usage with .items() method
plugins/modules/nios_dtc_monitor_snmp.py Removed six.iteritems import and replaced usage with .items() method
plugins/module_utils/api.py Removed six.iteritems import, replaced all usages with .items(), and updated safe_eval import/usage from validation module to ast.literal_eval
plugins/inventory/nios_inventory.py Removed six.iteritems import and replaced usage with .items() method
.github/workflows/ansible-test.yml Added Python 3.11 exclusion for devel, conditional utils.py handling for devel branch, coverage version pinning, and dynamic Python version selection for sanity tests
Comments suppressed due to low confidence (2)

plugins/module_utils/api.py:903

  • This assignment to 'txt' is unnecessary as it is redefined before this value is used.
    This assignment to 'txt' is unnecessary as it is redefined before this value is used.
                                txt = result['old_text']

plugins/module_utils/api.py:969

  • This assignment to 'txt' is unnecessary as it is redefined before this value is used.
    This assignment to 'txt' is unnecessary as it is redefined before this value is used.
                            txt = result['old_text']

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

txt = result['new_text']
except Exception:
raise TypeError('unable to evaluate string as dictionary')
txt = result['new_text']
Copy link

Copilot AI Dec 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is redundant code after the exception handling. Line 459 assigns txt = result['new_text'] after it was already assigned on line 456. This line should be removed as it's unreachable code that serves no purpose.

Suggested change
txt = result['new_text']

Copilot uses AI. Check for mistakes.
Comment on lines 907 to 908
txt = result['old_text']
old_text_exists = True
Copy link

Copilot AI Dec 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is redundant code after the exception handling. Lines 907-908 assign txt = result['old_text'] and old_text_exists = True after they were already assigned on lines 903-904. These lines should be removed as they're unreachable code that serves no purpose.

Suggested change
txt = result['old_text']
old_text_exists = True

Copilot uses AI. Check for mistakes.
Comment on lines 973 to 974
txt = result['old_text']
old_text_exists = True
Copy link

Copilot AI Dec 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is redundant code after the exception handling. Lines 973-974 assign txt = result['old_text'] and old_text_exists = True after they were already assigned on lines 969-970. These lines should be removed as they're unreachable code that serves no purpose.

Suggested change
txt = result['old_text']
old_text_exists = True

Copilot uses AI. Check for mistakes.
@@ -81,6 +83,14 @@ jobs:
git clone https://github.com/ansible/ansible.git -b ${{ matrix.ansible-version }}
if [ "${{ matrix.ansible-version }}" == "stable-2.16" ]; then cp -rf ansible/test/units/compat /home/runner/.ansible/collections/ansible_collections/infoblox/nios_modules/tests/unit/; fi
cp -rf ansible/test/units/modules/utils.py /home/runner/.ansible/collections/ansible_collections/infoblox/nios_modules/tests/unit/plugins/modules/
Copy link

Copilot AI Dec 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The line 85 that copies utils.py is redundant because the same operation is performed within the conditional block on lines 91-92 when the ansible-version is NOT 'devel'. This will result in the file being copied twice unnecessarily for non-devel versions.

Suggested change
cp -rf ansible/test/units/modules/utils.py /home/runner/.ansible/collections/ansible_collections/infoblox/nios_modules/tests/unit/plugins/modules/

Copilot uses AI. Check for mistakes.
- ansible-version: devel
python-version: '3.10'
- ansible-version: devel
python-version: '3.11'
Copy link

Copilot AI Dec 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a trailing whitespace character after '3.11' that should be removed to maintain clean formatting and consistency.

Suggested change
python-version: '3.11'
python-version: '3.11'

Copilot uses AI. Check for mistakes.
@JkhatriInfobox JkhatriInfobox changed the title Tests Fix Sanity and UT execution Dec 16, 2025
@JkhatriInfobox JkhatriInfobox merged commit 7ae1676 into infobloxopen:master Dec 16, 2025
28 of 40 checks passed
JkhatriInfobox pushed a commit to JkhatriInfobox/infoblox-ansible that referenced this pull request Jan 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants