Skip to content

Commit

Permalink
Add temporary ignore for PEP8 errors, will backport after release
Browse files Browse the repository at this point in the history
  • Loading branch information
tremble committed Oct 28, 2022
1 parent 2076920 commit 34f88ba
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 1 deletion.
4 changes: 3 additions & 1 deletion tests/sanity/ignore-2.14.txt
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
plugins/modules/route53.py validate-modules:parameter-state-invalid-choice # route53_info needs improvements before we can deprecate this
plugins/inventory/aws_ec2.py pep8:E275 # Need to partially backport 1181
plugins/modules/route53.py validate-modules:parameter-state-invalid-choice # route53_info needs improvements before we can deprecate this
plugins/modules/s3_object_info.py pep8:E275 # Need to partially backport 1181
2 changes: 2 additions & 0 deletions tests/sanity/ignore-2.15.txt
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
plugins/inventory/aws_ec2.py pep8:E275 # Need to partially backport 1181
plugins/modules/route53.py validate-modules:parameter-state-invalid-choice # route53_info needs improvements before we can deprecate this
plugins/modules/s3_object_info.py pep8:E275 # Need to partially backport 1181
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# (c) 2022 Red Hat Inc.
#
# This file is part of Ansible
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)

from __future__ import (absolute_import, division, print_function)
__metaclass__ = type

from copy import deepcopy
import pytest

import ansible_collections.amazon.aws.plugins.modules.ec2_security_group as ec2_security_group_module


VALID_RULES = [
dict(proto='all',),
dict(proto='tcp', from_port='1', to_port='65535',),
dict(proto='icmpv6', from_port='-1', to_port='-1',),
dict(proto='icmp', from_port='-1', to_port='-1',),
dict(proto='icmpv6', icmp_type='8', icmp_code='1'),
dict(proto='icmpv6', icmp_code='1'),
dict(proto='icmpv6', icmp_type='8'),
dict(proto='icmp', icmp_type='8', icmp_code='1'),
dict(proto='icmp', icmp_code='1'),
dict(proto='icmp', icmp_type='8'),
]

INVALID_RULES = [
(dict(proto='tcp', icmp_code='1',), r"Specify proto: icmp or icmpv6",),
(dict(proto='tcp', icmp_type='8',), r"Specify proto: icmp or icmpv6",),
(dict(proto='tcp', icmp_type='8', icmp_code='1',), r"Specify proto: icmp or icmpv6",),
(dict(proto='all', icmp_code='1',), r"Specify proto: icmp or icmpv6",),
(dict(proto='all', icmp_type='8',), r"Specify proto: icmp or icmpv6",),
(dict(proto='all', icmp_type='8', icmp_code='1',), r"Specify proto: icmp or icmpv6",),
]


@pytest.mark.parametrize("rule,error_msg", INVALID_RULES)
def test_validate_rule_invalid(rule, error_msg):
original_rule = deepcopy(rule)
with pytest.raises(ec2_security_group_module.SecurityGroupError, match=error_msg):
ec2_security_group_module.validate_rule(rule)
assert original_rule == rule


@pytest.mark.parametrize("rule", VALID_RULES)
def test_validate_rule_valid(rule):
original_rule = deepcopy(rule)
ec2_security_group_module.validate_rule(rule)
# validate_rule shouldn't change the rule
assert original_rule == rule

0 comments on commit 34f88ba

Please sign in to comment.