diff --git a/changelogs/fragments/test-python3-unicode-string.yaml b/changelogs/fragments/test-python3-unicode-string.yaml new file mode 100644 index 00000000000..e67d28c9242 --- /dev/null +++ b/changelogs/fragments/test-python3-unicode-string.yaml @@ -0,0 +1,3 @@ +--- +trivial: + - "unit-tests: Drop some ``u`` (unicode) string prefix that are not required anymore with Python3 (https://github.com/ansible-collections/amazon.aws/pull/1017)." diff --git a/plugins/module_utils/policy.py b/plugins/module_utils/policy.py index d8cf8469de8..4aeabd5f209 100644 --- a/plugins/module_utils/policy.py +++ b/plugins/module_utils/policy.py @@ -48,11 +48,11 @@ def _hashable_policy(policy, policy_list): 'Principal': {'AWS': ['arn:aws:iam::XXXXXXXXXXXX:user/username1', 'arn:aws:iam::XXXXXXXXXXXX:user/username2']} }]} Returned value: - [('Statement', ((('Action', (u's3:PutObjectAcl',)), - ('Effect', (u'Allow',)), - ('Principal', ('AWS', ((u'arn:aws:iam::XXXXXXXXXXXX:user/username1',), (u'arn:aws:iam::XXXXXXXXXXXX:user/username2',)))), - ('Resource', (u'arn:aws:s3:::test_policy/*',)), ('Sid', (u'AddCannedAcl2',)))), - ('Version', (u'2012-10-17',)))] + [('Statement', ((('Action', ('s3:PutObjectAcl',)), + ('Effect', ('Allow',)), + ('Principal', ('AWS', (('arn:aws:iam::XXXXXXXXXXXX:user/username1',), ('arn:aws:iam::XXXXXXXXXXXX:user/username2',)))), + ('Resource', ('arn:aws:s3:::test_policy/*',)), ('Sid', ('AddCannedAcl2',)))), + ('Version', ('2012-10-17',)))] """ # Amazon will automatically convert bool and int to strings for us diff --git a/tests/unit/plugins/inventory/test_aws_ec2.py b/tests/unit/plugins/inventory/test_aws_ec2.py index 028d4a37fde..fcff7ff75ec 100644 --- a/tests/unit/plugins/inventory/test_aws_ec2.py +++ b/tests/unit/plugins/inventory/test_aws_ec2.py @@ -30,81 +30,81 @@ instances = { - u'Instances': [ - {u'Monitoring': {u'State': 'disabled'}, - u'PublicDnsName': 'ec2-12-345-67-890.compute-1.amazonaws.com', - u'State': {u'Code': 16, u'Name': 'running'}, - u'EbsOptimized': False, - u'LaunchTime': datetime.datetime(2017, 10, 31, 12, 59, 25), - u'PublicIpAddress': '12.345.67.890', - u'PrivateIpAddress': '098.76.54.321', - u'ProductCodes': [], - u'VpcId': 'vpc-12345678', - u'StateTransitionReason': '', - u'InstanceId': 'i-00000000000000000', - u'EnaSupport': True, - u'ImageId': 'ami-12345678', - u'PrivateDnsName': 'ip-098-76-54-321.ec2.internal', - u'KeyName': 'testkey', - u'SecurityGroups': [{u'GroupName': 'default', u'GroupId': 'sg-12345678'}], - u'ClientToken': '', - u'SubnetId': 'subnet-12345678', - u'InstanceType': 't2.micro', - u'NetworkInterfaces': [ - {u'Status': 'in-use', - u'MacAddress': '12:a0:50:42:3d:a4', - u'SourceDestCheck': True, - u'VpcId': 'vpc-12345678', - u'Description': '', - u'NetworkInterfaceId': 'eni-12345678', - u'PrivateIpAddresses': [ - {u'PrivateDnsName': 'ip-098-76-54-321.ec2.internal', - u'PrivateIpAddress': '098.76.54.321', - u'Primary': True, - u'Association': - {u'PublicIp': '12.345.67.890', - u'PublicDnsName': 'ec2-12-345-67-890.compute-1.amazonaws.com', - u'IpOwnerId': 'amazon'}}], - u'PrivateDnsName': 'ip-098-76-54-321.ec2.internal', - u'Attachment': - {u'Status': 'attached', - u'DeviceIndex': 0, - u'DeleteOnTermination': True, - u'AttachmentId': 'eni-attach-12345678', - u'AttachTime': datetime.datetime(2017, 10, 31, 12, 59, 25)}, - u'Groups': [ - {u'GroupName': 'default', - u'GroupId': 'sg-12345678'}], - u'Ipv6Addresses': [], - u'OwnerId': '123456789000', - u'PrivateIpAddress': '098.76.54.321', - u'SubnetId': 'subnet-12345678', - u'Association': - {u'PublicIp': '12.345.67.890', - u'PublicDnsName': 'ec2-12-345-67-890.compute-1.amazonaws.com', - u'IpOwnerId': 'amazon'}}], - u'SourceDestCheck': True, - u'Placement': - {u'Tenancy': 'default', - u'GroupName': '', - u'AvailabilityZone': 'us-east-1c'}, - u'Hypervisor': 'xen', - u'BlockDeviceMappings': [ - {u'DeviceName': '/dev/xvda', - u'Ebs': - {u'Status': 'attached', - u'DeleteOnTermination': True, - u'VolumeId': 'vol-01234567890000000', - u'AttachTime': datetime.datetime(2017, 10, 31, 12, 59, 26)}}], - u'Architecture': 'x86_64', - u'RootDeviceType': 'ebs', - u'RootDeviceName': '/dev/xvda', - u'VirtualizationType': 'hvm', - u'Tags': [{u'Value': 'test', u'Key': 'ansible'}, {u'Value': 'aws_ec2', u'Key': 'Name'}], - u'AmiLaunchIndex': 0}], - u'ReservationId': 'r-01234567890000000', - u'Groups': [], - u'OwnerId': '123456789000' + 'Instances': [ + {'Monitoring': {'State': 'disabled'}, + 'PublicDnsName': 'ec2-12-345-67-890.compute-1.amazonaws.com', + 'State': {'Code': 16, 'Name': 'running'}, + 'EbsOptimized': False, + 'LaunchTime': datetime.datetime(2017, 10, 31, 12, 59, 25), + 'PublicIpAddress': '12.345.67.890', + 'PrivateIpAddress': '098.76.54.321', + 'ProductCodes': [], + 'VpcId': 'vpc-12345678', + 'StateTransitionReason': '', + 'InstanceId': 'i-00000000000000000', + 'EnaSupport': True, + 'ImageId': 'ami-12345678', + 'PrivateDnsName': 'ip-098-76-54-321.ec2.internal', + 'KeyName': 'testkey', + 'SecurityGroups': [{'GroupName': 'default', 'GroupId': 'sg-12345678'}], + 'ClientToken': '', + 'SubnetId': 'subnet-12345678', + 'InstanceType': 't2.micro', + 'NetworkInterfaces': [ + {'Status': 'in-use', + 'MacAddress': '12:a0:50:42:3d:a4', + 'SourceDestCheck': True, + 'VpcId': 'vpc-12345678', + 'Description': '', + 'NetworkInterfaceId': 'eni-12345678', + 'PrivateIpAddresses': [ + {'PrivateDnsName': 'ip-098-76-54-321.ec2.internal', + 'PrivateIpAddress': '098.76.54.321', + 'Primary': True, + 'Association': + {'PublicIp': '12.345.67.890', + 'PublicDnsName': 'ec2-12-345-67-890.compute-1.amazonaws.com', + 'IpOwnerId': 'amazon'}}], + 'PrivateDnsName': 'ip-098-76-54-321.ec2.internal', + 'Attachment': + {'Status': 'attached', + 'DeviceIndex': 0, + 'DeleteOnTermination': True, + 'AttachmentId': 'eni-attach-12345678', + 'AttachTime': datetime.datetime(2017, 10, 31, 12, 59, 25)}, + 'Groups': [ + {'GroupName': 'default', + 'GroupId': 'sg-12345678'}], + 'Ipv6Addresses': [], + 'OwnerId': '123456789000', + 'PrivateIpAddress': '098.76.54.321', + 'SubnetId': 'subnet-12345678', + 'Association': + {'PublicIp': '12.345.67.890', + 'PublicDnsName': 'ec2-12-345-67-890.compute-1.amazonaws.com', + 'IpOwnerId': 'amazon'}}], + 'SourceDestCheck': True, + 'Placement': + {'Tenancy': 'default', + 'GroupName': '', + 'AvailabilityZone': 'us-east-1c'}, + 'Hypervisor': 'xen', + 'BlockDeviceMappings': [ + {'DeviceName': '/dev/xvda', + 'Ebs': + {'Status': 'attached', + 'DeleteOnTermination': True, + 'VolumeId': 'vol-01234567890000000', + 'AttachTime': datetime.datetime(2017, 10, 31, 12, 59, 26)}}], + 'Architecture': 'x86_64', + 'RootDeviceType': 'ebs', + 'RootDeviceName': '/dev/xvda', + 'VirtualizationType': 'hvm', + 'Tags': [{'Value': 'test', 'Key': 'ansible'}, {'Value': 'aws_ec2', 'Key': 'Name'}], + 'AmiLaunchIndex': 0}], + 'ReservationId': 'r-01234567890000000', + 'Groups': [], + 'OwnerId': '123456789000' } diff --git a/tests/unit/plugins/modules/test_ec2_security_group.py b/tests/unit/plugins/modules/test_ec2_security_group.py index f185873f972..1ebbe86c680 100644 --- a/tests/unit/plugins/modules/test_ec2_security_group.py +++ b/tests/unit/plugins/modules/test_ec2_security_group.py @@ -7,20 +7,20 @@ def test_from_permission(): internal_http = { - u'FromPort': 80, - u'IpProtocol': 'tcp', - u'IpRanges': [ + 'FromPort': 80, + 'IpProtocol': 'tcp', + 'IpRanges': [ { - u'CidrIp': '10.0.0.0/8', - u'Description': 'Foo Bar Baz' + 'CidrIp': '10.0.0.0/8', + 'Description': 'Foo Bar Baz' }, ], - u'Ipv6Ranges': [ - {u'CidrIpv6': 'fe80::94cc:8aff:fef6:9cc/64'}, + 'Ipv6Ranges': [ + {'CidrIpv6': 'fe80::94cc:8aff:fef6:9cc/64'}, ], - u'PrefixListIds': [], - u'ToPort': 80, - u'UserIdGroupPairs': [], + 'PrefixListIds': [], + 'ToPort': 80, + 'UserIdGroupPairs': [], } perms = list(group_module.rule_from_group_permission(internal_http)) assert len(perms) == 2 @@ -42,13 +42,13 @@ def test_from_permission(): assert perms[0].port_range == (None, None) internal_prefix_http = { - u'FromPort': 80, - u'IpProtocol': 'tcp', - u'PrefixListIds': [ + 'FromPort': 80, + 'IpProtocol': 'tcp', + 'PrefixListIds': [ {'PrefixListId': 'p-1234'} ], - u'ToPort': 80, - u'UserIdGroupPairs': [], + 'ToPort': 80, + 'UserIdGroupPairs': [], } perms = list(group_module.rule_from_group_permission(internal_prefix_http)) assert len(perms) == 1