Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[6.13.z] Fix subnet tests #13295

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 13 additions & 12 deletions tests/foreman/cli/test_subnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import random
import re

from fauxfactory import gen_choice, gen_integer, gen_ipaddr
from fauxfactory import gen_choice, gen_integer, gen_ipaddr, gen_netmask
import pytest

from robottelo.constants import SUBNET_IPAM_TYPES
Expand Down Expand Up @@ -81,7 +81,7 @@ def test_positive_CRUD(module_target_sat):
"""
name = gen_choice(list(valid_data_list().values()))
pool = sorted(valid_addr_pools()[0])
mask = '255.255.255.0'
mask = gen_netmask()
# generate pool range from network address
network = gen_ipaddr()
from_ip = re.sub(r'\d+$', str(pool[0]), network)
Expand Down Expand Up @@ -119,7 +119,7 @@ def test_positive_CRUD(module_target_sat):
pool = sorted(valid_addr_pools()[0])
# generate pool range from network address
new_network = gen_ipaddr()
new_mask = '255.255.192.0'
new_mask = gen_netmask()
ip_from = re.sub(r'\d+$', str(pool[0]), new_network)
ip_to = re.sub(r'\d+$', str(pool[1]), new_network)
ipam_type = SUBNET_IPAM_TYPES['internal']
Expand Down Expand Up @@ -180,20 +180,19 @@ def test_negative_create_with_address_pool(pool, module_target_sat):

:CaseImportance: Medium
"""
mask = '255.255.255.0'
mask = gen_netmask()
network = gen_ipaddr()
opts = {'mask': mask, 'network': network}
options = {'mask': mask, 'network': network}
# generate pool range from network address
for key, val in pool.items():
opts[key] = re.sub(r'\d+$', str(val), network)
with pytest.raises(CLIFactoryError) as raise_ctx:
module_target_sat.cli_factory.make_subnet(opts)
assert 'Could not create the subnet:' in str(raise_ctx.value)
options[key] = re.sub(r'\d+$', str(val), network)
with pytest.raises(CLIFactoryError, match='Could not create the subnet:'):
module_target_sat.cli_factory.make_subnet(options)


@pytest.mark.tier2
@pytest.mark.parametrize('options', **parametrized(invalid_missing_attributes()))
def test_negative_update_attributes(options, module_target_sat):
def test_negative_update_attributes(request, options, module_target_sat):
"""Update subnet with invalid or missing required attributes

:parametrized: yes
Expand All @@ -206,17 +205,18 @@ def test_negative_update_attributes(options, module_target_sat):
"""
subnet = module_target_sat.cli_factory.make_subnet()
options['id'] = subnet['id']
request.addfinalizer(lambda: module_target_sat.cli.Subnet.delete({'id': subnet['id']}))
with pytest.raises(CLIReturnCodeError, match='Could not update the subnet:'):
module_target_sat.cli.Subnet.update(options)
# check - subnet is not updated
result = module_target_sat.cli.Subnet.info({'id': subnet['id']})
for key in options.keys():
for key in ['name', 'network-addr', 'network-mask']:
assert subnet[key] == result[key]


@pytest.mark.tier2
@pytest.mark.parametrize('options', **parametrized(invalid_addr_pools()))
def test_negative_update_address_pool(options, module_target_sat):
def test_negative_update_address_pool(request, options, module_target_sat):
"""Update subnet with invalid address pool

:parametrized: yes
Expand All @@ -229,6 +229,7 @@ def test_negative_update_address_pool(options, module_target_sat):
"""
subnet = module_target_sat.cli_factory.make_subnet()
opts = {'id': subnet['id']}
request.addfinalizer(lambda: module_target_sat.cli.Subnet.delete({'id': subnet['id']}))
# generate pool range from network address
for key, val in options.items():
opts[key] = re.sub(r'\d+$', str(val), subnet['network-addr'])
Expand Down