Merge "Use FakeProject and FakeDomain classes in unit tests of networkv2"
This commit is contained in:
commit
63a6789add
@ -11,7 +11,6 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
#
|
#
|
||||||
|
|
||||||
import copy
|
|
||||||
import mock
|
import mock
|
||||||
|
|
||||||
from mock import call
|
from mock import call
|
||||||
@ -35,11 +34,13 @@ class TestAddressScope(network_fakes.TestNetworkV2):
|
|||||||
|
|
||||||
class TestCreateAddressScope(TestAddressScope):
|
class TestCreateAddressScope(TestAddressScope):
|
||||||
|
|
||||||
|
project = identity_fakes_v3.FakeProject.create_one_project()
|
||||||
|
domain = identity_fakes_v3.FakeDomain.create_one_domain()
|
||||||
# The new address scope created.
|
# The new address scope created.
|
||||||
new_address_scope = (
|
new_address_scope = (
|
||||||
network_fakes.FakeAddressScope.create_one_address_scope(
|
network_fakes.FakeAddressScope.create_one_address_scope(
|
||||||
attrs={
|
attrs={
|
||||||
'tenant_id': identity_fakes_v3.project_id,
|
'tenant_id': project.id,
|
||||||
}
|
}
|
||||||
))
|
))
|
||||||
columns = (
|
columns = (
|
||||||
@ -75,19 +76,11 @@ class TestCreateAddressScope(TestAddressScope):
|
|||||||
|
|
||||||
# Get a shortcut to the ProjectManager Mock
|
# Get a shortcut to the ProjectManager Mock
|
||||||
self.projects_mock = self.identity.projects
|
self.projects_mock = self.identity.projects
|
||||||
self.projects_mock.get.return_value = fakes.FakeResource(
|
self.projects_mock.get.return_value = self.project
|
||||||
None,
|
|
||||||
copy.deepcopy(identity_fakes_v3.PROJECT),
|
|
||||||
loaded=True,
|
|
||||||
)
|
|
||||||
|
|
||||||
# Get a shortcut to the DomainManager Mock
|
# Get a shortcut to the DomainManager Mock
|
||||||
self.domains_mock = self.identity.domains
|
self.domains_mock = self.identity.domains
|
||||||
self.domains_mock.get.return_value = fakes.FakeResource(
|
self.domains_mock.get.return_value = self.domain
|
||||||
None,
|
|
||||||
copy.deepcopy(identity_fakes_v3.DOMAIN),
|
|
||||||
loaded=True,
|
|
||||||
)
|
|
||||||
|
|
||||||
def test_create_no_options(self):
|
def test_create_no_options(self):
|
||||||
arglist = []
|
arglist = []
|
||||||
@ -121,15 +114,15 @@ class TestCreateAddressScope(TestAddressScope):
|
|||||||
arglist = [
|
arglist = [
|
||||||
'--ip-version', str(self.new_address_scope.ip_version),
|
'--ip-version', str(self.new_address_scope.ip_version),
|
||||||
'--share',
|
'--share',
|
||||||
'--project', identity_fakes_v3.project_name,
|
'--project', self.project.name,
|
||||||
'--project-domain', identity_fakes_v3.domain_name,
|
'--project-domain', self.domain.name,
|
||||||
self.new_address_scope.name,
|
self.new_address_scope.name,
|
||||||
]
|
]
|
||||||
verifylist = [
|
verifylist = [
|
||||||
('ip_version', self.new_address_scope.ip_version),
|
('ip_version', self.new_address_scope.ip_version),
|
||||||
('share', True),
|
('share', True),
|
||||||
('project', identity_fakes_v3.project_name),
|
('project', self.project.name),
|
||||||
('project_domain', identity_fakes_v3.domain_name),
|
('project_domain', self.domain.name),
|
||||||
('name', self.new_address_scope.name),
|
('name', self.new_address_scope.name),
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -139,7 +132,7 @@ class TestCreateAddressScope(TestAddressScope):
|
|||||||
self.network.create_address_scope.assert_called_once_with(**{
|
self.network.create_address_scope.assert_called_once_with(**{
|
||||||
'ip_version': self.new_address_scope.ip_version,
|
'ip_version': self.new_address_scope.ip_version,
|
||||||
'shared': True,
|
'shared': True,
|
||||||
'tenant_id': identity_fakes_v3.project_id,
|
'tenant_id': self.project.id,
|
||||||
'name': self.new_address_scope.name,
|
'name': self.new_address_scope.name,
|
||||||
})
|
})
|
||||||
self.assertEqual(self.columns, columns)
|
self.assertEqual(self.columns, columns)
|
||||||
|
@ -11,7 +11,6 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
#
|
#
|
||||||
|
|
||||||
import copy
|
|
||||||
import mock
|
import mock
|
||||||
|
|
||||||
from osc_lib import utils as common_utils
|
from osc_lib import utils as common_utils
|
||||||
@ -41,11 +40,8 @@ class TestIPAvailability(network_fakes.TestNetworkV2):
|
|||||||
|
|
||||||
# Get a shortcut to the ProjectManager Mock
|
# Get a shortcut to the ProjectManager Mock
|
||||||
self.projects_mock = self.identity.projects
|
self.projects_mock = self.identity.projects
|
||||||
self.projects_mock.get.return_value = fakes.FakeResource(
|
self.project = identity_fakes.FakeProject.create_one_project()
|
||||||
None,
|
self.projects_mock.get.return_value = self.project
|
||||||
copy.deepcopy(identity_fakes.PROJECT),
|
|
||||||
loaded=True,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class TestListIPAvailability(TestIPAvailability):
|
class TestListIPAvailability(TestIPAvailability):
|
||||||
@ -109,16 +105,16 @@ class TestListIPAvailability(TestIPAvailability):
|
|||||||
|
|
||||||
def test_list_project(self):
|
def test_list_project(self):
|
||||||
arglist = [
|
arglist = [
|
||||||
'--project', identity_fakes.project_name
|
'--project', self.project.name
|
||||||
]
|
]
|
||||||
verifylist = [
|
verifylist = [
|
||||||
('project', identity_fakes.project_name)
|
('project', self.project.name)
|
||||||
]
|
]
|
||||||
|
|
||||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||||
|
|
||||||
columns, data = self.cmd.take_action(parsed_args)
|
columns, data = self.cmd.take_action(parsed_args)
|
||||||
filters = {'tenant_id': identity_fakes.project_id,
|
filters = {'tenant_id': self.project.id,
|
||||||
'ip_version': 4}
|
'ip_version': 4}
|
||||||
|
|
||||||
self.network.network_ip_availabilities.assert_called_once_with(
|
self.network.network_ip_availabilities.assert_called_once_with(
|
||||||
|
@ -11,7 +11,6 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
#
|
#
|
||||||
|
|
||||||
import copy
|
|
||||||
import mock
|
import mock
|
||||||
from mock import call
|
from mock import call
|
||||||
|
|
||||||
@ -40,10 +39,12 @@ class TestNetwork(network_fakes.TestNetworkV2):
|
|||||||
|
|
||||||
class TestCreateNetworkIdentityV3(TestNetwork):
|
class TestCreateNetworkIdentityV3(TestNetwork):
|
||||||
|
|
||||||
|
project = identity_fakes_v3.FakeProject.create_one_project()
|
||||||
|
domain = identity_fakes_v3.FakeDomain.create_one_domain()
|
||||||
# The new network created.
|
# The new network created.
|
||||||
_network = network_fakes.FakeNetwork.create_one_network(
|
_network = network_fakes.FakeNetwork.create_one_network(
|
||||||
attrs={
|
attrs={
|
||||||
'tenant_id': identity_fakes_v3.project_id,
|
'tenant_id': project.id,
|
||||||
'availability_zone_hints': ["nova"],
|
'availability_zone_hints': ["nova"],
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@ -96,19 +97,11 @@ class TestCreateNetworkIdentityV3(TestNetwork):
|
|||||||
|
|
||||||
# Get a shortcut to the ProjectManager Mock
|
# Get a shortcut to the ProjectManager Mock
|
||||||
self.projects_mock = self.identity.projects
|
self.projects_mock = self.identity.projects
|
||||||
self.projects_mock.get.return_value = fakes.FakeResource(
|
self.projects_mock.get.return_value = self.project
|
||||||
None,
|
|
||||||
copy.deepcopy(identity_fakes_v3.PROJECT),
|
|
||||||
loaded=True,
|
|
||||||
)
|
|
||||||
|
|
||||||
# Get a shortcut to the DomainManager Mock
|
# Get a shortcut to the DomainManager Mock
|
||||||
self.domains_mock = self.identity.domains
|
self.domains_mock = self.identity.domains
|
||||||
self.domains_mock.get.return_value = fakes.FakeResource(
|
self.domains_mock.get.return_value = self.domain
|
||||||
None,
|
|
||||||
copy.deepcopy(identity_fakes_v3.DOMAIN),
|
|
||||||
loaded=True,
|
|
||||||
)
|
|
||||||
|
|
||||||
def test_create_no_options(self):
|
def test_create_no_options(self):
|
||||||
arglist = []
|
arglist = []
|
||||||
@ -143,8 +136,8 @@ class TestCreateNetworkIdentityV3(TestNetwork):
|
|||||||
arglist = [
|
arglist = [
|
||||||
"--disable",
|
"--disable",
|
||||||
"--share",
|
"--share",
|
||||||
"--project", identity_fakes_v3.project_name,
|
"--project", self.project.name,
|
||||||
"--project-domain", identity_fakes_v3.domain_name,
|
"--project-domain", self.domain.name,
|
||||||
"--availability-zone-hint", "nova",
|
"--availability-zone-hint", "nova",
|
||||||
"--external", "--default",
|
"--external", "--default",
|
||||||
"--provider-network-type", "vlan",
|
"--provider-network-type", "vlan",
|
||||||
@ -156,8 +149,8 @@ class TestCreateNetworkIdentityV3(TestNetwork):
|
|||||||
verifylist = [
|
verifylist = [
|
||||||
('disable', True),
|
('disable', True),
|
||||||
('share', True),
|
('share', True),
|
||||||
('project', identity_fakes_v3.project_name),
|
('project', self.project.name),
|
||||||
('project_domain', identity_fakes_v3.domain_name),
|
('project_domain', self.domain.name),
|
||||||
('availability_zone_hints', ["nova"]),
|
('availability_zone_hints', ["nova"]),
|
||||||
('external', True),
|
('external', True),
|
||||||
('default', True),
|
('default', True),
|
||||||
@ -176,7 +169,7 @@ class TestCreateNetworkIdentityV3(TestNetwork):
|
|||||||
'availability_zone_hints': ["nova"],
|
'availability_zone_hints': ["nova"],
|
||||||
'name': self._network.name,
|
'name': self._network.name,
|
||||||
'shared': True,
|
'shared': True,
|
||||||
'tenant_id': identity_fakes_v3.project_id,
|
'tenant_id': self.project.id,
|
||||||
'is_default': True,
|
'is_default': True,
|
||||||
'router:external': True,
|
'router:external': True,
|
||||||
'provider:network_type': 'vlan',
|
'provider:network_type': 'vlan',
|
||||||
@ -214,9 +207,10 @@ class TestCreateNetworkIdentityV3(TestNetwork):
|
|||||||
|
|
||||||
class TestCreateNetworkIdentityV2(TestNetwork):
|
class TestCreateNetworkIdentityV2(TestNetwork):
|
||||||
|
|
||||||
|
project = identity_fakes_v2.FakeProject.create_one_project()
|
||||||
# The new network created.
|
# The new network created.
|
||||||
_network = network_fakes.FakeNetwork.create_one_network(
|
_network = network_fakes.FakeNetwork.create_one_network(
|
||||||
attrs={'tenant_id': identity_fakes_v2.project_id}
|
attrs={'tenant_id': project.id}
|
||||||
)
|
)
|
||||||
|
|
||||||
columns = (
|
columns = (
|
||||||
@ -267,24 +261,20 @@ class TestCreateNetworkIdentityV2(TestNetwork):
|
|||||||
|
|
||||||
# Get a shortcut to the ProjectManager Mock
|
# Get a shortcut to the ProjectManager Mock
|
||||||
self.projects_mock = self.identity.tenants
|
self.projects_mock = self.identity.tenants
|
||||||
self.projects_mock.get.return_value = fakes.FakeResource(
|
self.projects_mock.get.return_value = self.project
|
||||||
None,
|
|
||||||
copy.deepcopy(identity_fakes_v2.PROJECT),
|
|
||||||
loaded=True,
|
|
||||||
)
|
|
||||||
|
|
||||||
# There is no DomainManager Mock in fake identity v2.
|
# There is no DomainManager Mock in fake identity v2.
|
||||||
|
|
||||||
def test_create_with_project_identityv2(self):
|
def test_create_with_project_identityv2(self):
|
||||||
arglist = [
|
arglist = [
|
||||||
"--project", identity_fakes_v2.project_name,
|
"--project", self.project.name,
|
||||||
self._network.name,
|
self._network.name,
|
||||||
]
|
]
|
||||||
verifylist = [
|
verifylist = [
|
||||||
('enable', True),
|
('enable', True),
|
||||||
('share', None),
|
('share', None),
|
||||||
('name', self._network.name),
|
('name', self._network.name),
|
||||||
('project', identity_fakes_v2.project_name),
|
('project', self.project.name),
|
||||||
('external', False),
|
('external', False),
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -294,22 +284,22 @@ class TestCreateNetworkIdentityV2(TestNetwork):
|
|||||||
self.network.create_network.assert_called_once_with(**{
|
self.network.create_network.assert_called_once_with(**{
|
||||||
'admin_state_up': True,
|
'admin_state_up': True,
|
||||||
'name': self._network.name,
|
'name': self._network.name,
|
||||||
'tenant_id': identity_fakes_v2.project_id,
|
'tenant_id': self.project.id,
|
||||||
})
|
})
|
||||||
self.assertEqual(self.columns, columns)
|
self.assertEqual(self.columns, columns)
|
||||||
self.assertEqual(self.data, data)
|
self.assertEqual(self.data, data)
|
||||||
|
|
||||||
def test_create_with_domain_identityv2(self):
|
def test_create_with_domain_identityv2(self):
|
||||||
arglist = [
|
arglist = [
|
||||||
"--project", identity_fakes_v3.project_name,
|
"--project", self.project.name,
|
||||||
"--project-domain", identity_fakes_v3.domain_name,
|
"--project-domain", "domain-name",
|
||||||
self._network.name,
|
self._network.name,
|
||||||
]
|
]
|
||||||
verifylist = [
|
verifylist = [
|
||||||
('enable', True),
|
('enable', True),
|
||||||
('share', None),
|
('share', None),
|
||||||
('project', identity_fakes_v3.project_name),
|
('project', self.project.name),
|
||||||
('project_domain', identity_fakes_v3.domain_name),
|
('project_domain', "domain-name"),
|
||||||
('name', self._network.name),
|
('name', self._network.name),
|
||||||
('external', False),
|
('external', False),
|
||||||
]
|
]
|
||||||
|
@ -11,7 +11,6 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
#
|
#
|
||||||
|
|
||||||
import copy
|
|
||||||
import mock
|
import mock
|
||||||
from mock import call
|
from mock import call
|
||||||
|
|
||||||
@ -45,6 +44,8 @@ class TestSecurityGroupCompute(compute_fakes.TestComputev2):
|
|||||||
|
|
||||||
class TestCreateSecurityGroupNetwork(TestSecurityGroupNetwork):
|
class TestCreateSecurityGroupNetwork(TestSecurityGroupNetwork):
|
||||||
|
|
||||||
|
project = identity_fakes.FakeProject.create_one_project()
|
||||||
|
domain = identity_fakes.FakeDomain.create_one_domain()
|
||||||
# The security group to be created.
|
# The security group to be created.
|
||||||
_security_group = \
|
_security_group = \
|
||||||
network_fakes.FakeSecurityGroup.create_one_security_group()
|
network_fakes.FakeSecurityGroup.create_one_security_group()
|
||||||
@ -81,19 +82,11 @@ class TestCreateSecurityGroupNetwork(TestSecurityGroupNetwork):
|
|||||||
|
|
||||||
# Get a shortcut to the ProjectManager Mock
|
# Get a shortcut to the ProjectManager Mock
|
||||||
self.projects_mock = self.identity.projects
|
self.projects_mock = self.identity.projects
|
||||||
self.projects_mock.get.return_value = fakes.FakeResource(
|
self.projects_mock.get.return_value = self.project
|
||||||
None,
|
|
||||||
copy.deepcopy(identity_fakes.PROJECT),
|
|
||||||
loaded=True,
|
|
||||||
)
|
|
||||||
|
|
||||||
# Get a shortcut to the DomainManager Mock
|
# Get a shortcut to the DomainManager Mock
|
||||||
self.domains_mock = self.identity.domains
|
self.domains_mock = self.identity.domains
|
||||||
self.domains_mock.get.return_value = fakes.FakeResource(
|
self.domains_mock.get.return_value = self.domain
|
||||||
None,
|
|
||||||
copy.deepcopy(identity_fakes.DOMAIN),
|
|
||||||
loaded=True,
|
|
||||||
)
|
|
||||||
|
|
||||||
# Get the command object to test
|
# Get the command object to test
|
||||||
self.cmd = security_group.CreateSecurityGroup(self.app, self.namespace)
|
self.cmd = security_group.CreateSecurityGroup(self.app, self.namespace)
|
||||||
@ -123,15 +116,15 @@ class TestCreateSecurityGroupNetwork(TestSecurityGroupNetwork):
|
|||||||
def test_create_all_options(self):
|
def test_create_all_options(self):
|
||||||
arglist = [
|
arglist = [
|
||||||
'--description', self._security_group.description,
|
'--description', self._security_group.description,
|
||||||
'--project', identity_fakes.project_name,
|
'--project', self.project.name,
|
||||||
'--project-domain', identity_fakes.domain_name,
|
'--project-domain', self.domain.name,
|
||||||
self._security_group.name,
|
self._security_group.name,
|
||||||
]
|
]
|
||||||
verifylist = [
|
verifylist = [
|
||||||
('description', self._security_group.description),
|
('description', self._security_group.description),
|
||||||
('name', self._security_group.name),
|
('name', self._security_group.name),
|
||||||
('project', identity_fakes.project_name),
|
('project', self.project.name),
|
||||||
('project_domain', identity_fakes.domain_name),
|
('project_domain', self.domain.name),
|
||||||
]
|
]
|
||||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||||
|
|
||||||
@ -140,7 +133,7 @@ class TestCreateSecurityGroupNetwork(TestSecurityGroupNetwork):
|
|||||||
self.network.create_security_group.assert_called_once_with(**{
|
self.network.create_security_group.assert_called_once_with(**{
|
||||||
'description': self._security_group.description,
|
'description': self._security_group.description,
|
||||||
'name': self._security_group.name,
|
'name': self._security_group.name,
|
||||||
'tenant_id': identity_fakes.project_id,
|
'tenant_id': self.project.id,
|
||||||
})
|
})
|
||||||
self.assertEqual(self.columns, columns)
|
self.assertEqual(self.columns, columns)
|
||||||
self.assertEqual(self.data, data)
|
self.assertEqual(self.data, data)
|
||||||
@ -148,6 +141,8 @@ class TestCreateSecurityGroupNetwork(TestSecurityGroupNetwork):
|
|||||||
|
|
||||||
class TestCreateSecurityGroupCompute(TestSecurityGroupCompute):
|
class TestCreateSecurityGroupCompute(TestSecurityGroupCompute):
|
||||||
|
|
||||||
|
project = identity_fakes.FakeProject.create_one_project()
|
||||||
|
domain = identity_fakes.FakeDomain.create_one_domain()
|
||||||
# The security group to be shown.
|
# The security group to be shown.
|
||||||
_security_group = \
|
_security_group = \
|
||||||
compute_fakes.FakeSecurityGroup.create_one_security_group()
|
compute_fakes.FakeSecurityGroup.create_one_security_group()
|
||||||
@ -184,8 +179,8 @@ class TestCreateSecurityGroupCompute(TestSecurityGroupCompute):
|
|||||||
|
|
||||||
def test_create_network_options(self):
|
def test_create_network_options(self):
|
||||||
arglist = [
|
arglist = [
|
||||||
'--project', identity_fakes.project_name,
|
'--project', self.project.name,
|
||||||
'--project-domain', identity_fakes.domain_name,
|
'--project-domain', self.domain.name,
|
||||||
self._security_group.name,
|
self._security_group.name,
|
||||||
]
|
]
|
||||||
self.assertRaises(tests_utils.ParserException,
|
self.assertRaises(tests_utils.ParserException,
|
||||||
|
@ -46,6 +46,8 @@ class TestSecurityGroupRuleCompute(compute_fakes.TestComputev2):
|
|||||||
|
|
||||||
class TestCreateSecurityGroupRuleNetwork(TestSecurityGroupRuleNetwork):
|
class TestCreateSecurityGroupRuleNetwork(TestSecurityGroupRuleNetwork):
|
||||||
|
|
||||||
|
project = identity_fakes.FakeProject.create_one_project()
|
||||||
|
domain = identity_fakes.FakeDomain.create_one_domain()
|
||||||
# The security group rule to be created.
|
# The security group rule to be created.
|
||||||
_security_group_rule = None
|
_security_group_rule = None
|
||||||
|
|
||||||
@ -103,19 +105,11 @@ class TestCreateSecurityGroupRuleNetwork(TestSecurityGroupRuleNetwork):
|
|||||||
|
|
||||||
# Get a shortcut to the ProjectManager Mock
|
# Get a shortcut to the ProjectManager Mock
|
||||||
self.projects_mock = self.identity.projects
|
self.projects_mock = self.identity.projects
|
||||||
self.projects_mock.get.return_value = fakes.FakeResource(
|
self.projects_mock.get.return_value = self.project
|
||||||
None,
|
|
||||||
copy.deepcopy(identity_fakes.PROJECT),
|
|
||||||
loaded=True,
|
|
||||||
)
|
|
||||||
|
|
||||||
# Get a shortcut to the DomainManager Mock
|
# Get a shortcut to the DomainManager Mock
|
||||||
self.domains_mock = self.identity.domains
|
self.domains_mock = self.identity.domains
|
||||||
self.domains_mock.get.return_value = fakes.FakeResource(
|
self.domains_mock.get.return_value = self.domain
|
||||||
None,
|
|
||||||
copy.deepcopy(identity_fakes.DOMAIN),
|
|
||||||
loaded=True,
|
|
||||||
)
|
|
||||||
|
|
||||||
# Get the command object to test
|
# Get the command object to test
|
||||||
self.cmd = security_group_rule.CreateSecurityGroupRule(
|
self.cmd = security_group_rule.CreateSecurityGroupRule(
|
||||||
@ -306,8 +300,8 @@ class TestCreateSecurityGroupRuleNetwork(TestSecurityGroupRuleNetwork):
|
|||||||
'--dst-port', str(self._security_group_rule.port_range_min),
|
'--dst-port', str(self._security_group_rule.port_range_min),
|
||||||
'--egress',
|
'--egress',
|
||||||
'--ethertype', self._security_group_rule.ethertype,
|
'--ethertype', self._security_group_rule.ethertype,
|
||||||
'--project', identity_fakes.project_name,
|
'--project', self.project.name,
|
||||||
'--project-domain', identity_fakes.domain_name,
|
'--project-domain', self.domain.name,
|
||||||
'--protocol', self._security_group_rule.protocol,
|
'--protocol', self._security_group_rule.protocol,
|
||||||
self._security_group.id,
|
self._security_group.id,
|
||||||
]
|
]
|
||||||
@ -316,8 +310,8 @@ class TestCreateSecurityGroupRuleNetwork(TestSecurityGroupRuleNetwork):
|
|||||||
self._security_group_rule.port_range_max)),
|
self._security_group_rule.port_range_max)),
|
||||||
('egress', True),
|
('egress', True),
|
||||||
('ethertype', self._security_group_rule.ethertype),
|
('ethertype', self._security_group_rule.ethertype),
|
||||||
('project', identity_fakes.project_name),
|
('project', self.project.name),
|
||||||
('project_domain', identity_fakes.domain_name),
|
('project_domain', self.domain.name),
|
||||||
('protocol', self._security_group_rule.protocol),
|
('protocol', self._security_group_rule.protocol),
|
||||||
('group', self._security_group.id),
|
('group', self._security_group.id),
|
||||||
]
|
]
|
||||||
@ -332,7 +326,7 @@ class TestCreateSecurityGroupRuleNetwork(TestSecurityGroupRuleNetwork):
|
|||||||
'port_range_min': self._security_group_rule.port_range_min,
|
'port_range_min': self._security_group_rule.port_range_min,
|
||||||
'protocol': self._security_group_rule.protocol,
|
'protocol': self._security_group_rule.protocol,
|
||||||
'security_group_id': self._security_group.id,
|
'security_group_id': self._security_group.id,
|
||||||
'tenant_id': identity_fakes.project_id,
|
'tenant_id': self.project.id,
|
||||||
})
|
})
|
||||||
self.assertEqual(self.expected_columns, columns)
|
self.assertEqual(self.expected_columns, columns)
|
||||||
self.assertEqual(self.expected_data, data)
|
self.assertEqual(self.expected_data, data)
|
||||||
@ -470,6 +464,8 @@ class TestCreateSecurityGroupRuleNetwork(TestSecurityGroupRuleNetwork):
|
|||||||
|
|
||||||
class TestCreateSecurityGroupRuleCompute(TestSecurityGroupRuleCompute):
|
class TestCreateSecurityGroupRuleCompute(TestSecurityGroupRuleCompute):
|
||||||
|
|
||||||
|
project = identity_fakes.FakeProject.create_one_project()
|
||||||
|
domain = identity_fakes.FakeDomain.create_one_domain()
|
||||||
# The security group rule to be created.
|
# The security group rule to be created.
|
||||||
_security_group_rule = None
|
_security_group_rule = None
|
||||||
|
|
||||||
@ -534,8 +530,8 @@ class TestCreateSecurityGroupRuleCompute(TestSecurityGroupRuleCompute):
|
|||||||
'--ethertype', 'IPv4',
|
'--ethertype', 'IPv4',
|
||||||
'--icmp-type', '3',
|
'--icmp-type', '3',
|
||||||
'--icmp-code', '11',
|
'--icmp-code', '11',
|
||||||
'--project', identity_fakes.project_name,
|
'--project', self.project.name,
|
||||||
'--project-domain', identity_fakes.domain_name,
|
'--project-domain', self.domain.name,
|
||||||
self._security_group.id,
|
self._security_group.id,
|
||||||
]
|
]
|
||||||
self.assertRaises(tests_utils.ParserException,
|
self.assertRaises(tests_utils.ParserException,
|
||||||
|
@ -11,7 +11,6 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
#
|
#
|
||||||
|
|
||||||
import copy
|
|
||||||
import mock
|
import mock
|
||||||
from mock import call
|
from mock import call
|
||||||
|
|
||||||
@ -36,10 +35,12 @@ class TestSubnet(network_fakes.TestNetworkV2):
|
|||||||
|
|
||||||
class TestCreateSubnet(TestSubnet):
|
class TestCreateSubnet(TestSubnet):
|
||||||
|
|
||||||
|
project = identity_fakes_v3.FakeProject.create_one_project()
|
||||||
|
domain = identity_fakes_v3.FakeDomain.create_one_domain()
|
||||||
# An IPv4 subnet to be created with mostly default values
|
# An IPv4 subnet to be created with mostly default values
|
||||||
_subnet = network_fakes.FakeSubnet.create_one_subnet(
|
_subnet = network_fakes.FakeSubnet.create_one_subnet(
|
||||||
attrs={
|
attrs={
|
||||||
'tenant_id': identity_fakes_v3.project_id,
|
'tenant_id': project.id,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -49,7 +50,7 @@ class TestCreateSubnet(TestSubnet):
|
|||||||
# An IPv4 subnet to be created using a specific subnet pool
|
# An IPv4 subnet to be created using a specific subnet pool
|
||||||
_subnet_from_pool = network_fakes.FakeSubnet.create_one_subnet(
|
_subnet_from_pool = network_fakes.FakeSubnet.create_one_subnet(
|
||||||
attrs={
|
attrs={
|
||||||
'tenant_id': identity_fakes_v3.project_id,
|
'tenant_id': project.id,
|
||||||
'subnetpool_id': _subnet_pool.id,
|
'subnetpool_id': _subnet_pool.id,
|
||||||
'dns_nameservers': ['8.8.8.8',
|
'dns_nameservers': ['8.8.8.8',
|
||||||
'8.8.4.4'],
|
'8.8.4.4'],
|
||||||
@ -63,7 +64,7 @@ class TestCreateSubnet(TestSubnet):
|
|||||||
# An IPv6 subnet to be created with most options specified
|
# An IPv6 subnet to be created with most options specified
|
||||||
_subnet_ipv6 = network_fakes.FakeSubnet.create_one_subnet(
|
_subnet_ipv6 = network_fakes.FakeSubnet.create_one_subnet(
|
||||||
attrs={
|
attrs={
|
||||||
'tenant_id': identity_fakes_v3.project_id,
|
'tenant_id': project.id,
|
||||||
'cidr': 'fe80:0:0:a00a::/64',
|
'cidr': 'fe80:0:0:a00a::/64',
|
||||||
'enable_dhcp': True,
|
'enable_dhcp': True,
|
||||||
'dns_nameservers': ['fe80:27ff:a00a:f00f::ffff',
|
'dns_nameservers': ['fe80:27ff:a00a:f00f::ffff',
|
||||||
@ -187,19 +188,11 @@ class TestCreateSubnet(TestSubnet):
|
|||||||
|
|
||||||
# Get a shortcut to the ProjectManager Mock
|
# Get a shortcut to the ProjectManager Mock
|
||||||
self.projects_mock = self.identity.projects
|
self.projects_mock = self.identity.projects
|
||||||
self.projects_mock.get.return_value = fakes.FakeResource(
|
self.projects_mock.get.return_value = self.project
|
||||||
None,
|
|
||||||
copy.deepcopy(identity_fakes_v3.PROJECT),
|
|
||||||
loaded=True,
|
|
||||||
)
|
|
||||||
|
|
||||||
# Get a shortcut to the DomainManager Mock
|
# Get a shortcut to the DomainManager Mock
|
||||||
self.domains_mock = self.identity.domains
|
self.domains_mock = self.identity.domains
|
||||||
self.domains_mock.get.return_value = fakes.FakeResource(
|
self.domains_mock.get.return_value = self.domain
|
||||||
None,
|
|
||||||
copy.deepcopy(identity_fakes_v3.DOMAIN),
|
|
||||||
loaded=True,
|
|
||||||
)
|
|
||||||
|
|
||||||
# Mock SDK calls for all tests.
|
# Mock SDK calls for all tests.
|
||||||
self.network.find_network = mock.Mock(return_value=self._network)
|
self.network.find_network = mock.Mock(return_value=self._network)
|
||||||
|
@ -12,7 +12,6 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
import copy
|
|
||||||
import mock
|
import mock
|
||||||
from mock import call
|
from mock import call
|
||||||
|
|
||||||
@ -37,6 +36,8 @@ class TestSubnetPool(network_fakes.TestNetworkV2):
|
|||||||
|
|
||||||
class TestCreateSubnetPool(TestSubnetPool):
|
class TestCreateSubnetPool(TestSubnetPool):
|
||||||
|
|
||||||
|
project = identity_fakes_v3.FakeProject.create_one_project()
|
||||||
|
domain = identity_fakes_v3.FakeDomain.create_one_domain()
|
||||||
# The new subnet pool to create.
|
# The new subnet pool to create.
|
||||||
_subnet_pool = network_fakes.FakeSubnetPool.create_one_subnet_pool()
|
_subnet_pool = network_fakes.FakeSubnetPool.create_one_subnet_pool()
|
||||||
|
|
||||||
@ -93,19 +94,11 @@ class TestCreateSubnetPool(TestSubnetPool):
|
|||||||
|
|
||||||
# Get a shortcut to the ProjectManager Mock
|
# Get a shortcut to the ProjectManager Mock
|
||||||
self.projects_mock = self.identity.projects
|
self.projects_mock = self.identity.projects
|
||||||
self.projects_mock.get.return_value = fakes.FakeResource(
|
self.projects_mock.get.return_value = self.project
|
||||||
None,
|
|
||||||
copy.deepcopy(identity_fakes_v3.PROJECT),
|
|
||||||
loaded=True,
|
|
||||||
)
|
|
||||||
|
|
||||||
# Get a shortcut to the DomainManager Mock
|
# Get a shortcut to the DomainManager Mock
|
||||||
self.domains_mock = self.identity.domains
|
self.domains_mock = self.identity.domains
|
||||||
self.domains_mock.get.return_value = fakes.FakeResource(
|
self.domains_mock.get.return_value = self.domain
|
||||||
None,
|
|
||||||
copy.deepcopy(identity_fakes_v3.DOMAIN),
|
|
||||||
loaded=True,
|
|
||||||
)
|
|
||||||
|
|
||||||
def test_create_no_options(self):
|
def test_create_no_options(self):
|
||||||
arglist = []
|
arglist = []
|
||||||
@ -191,14 +184,14 @@ class TestCreateSubnetPool(TestSubnetPool):
|
|||||||
def test_create_project_domain(self):
|
def test_create_project_domain(self):
|
||||||
arglist = [
|
arglist = [
|
||||||
'--pool-prefix', '10.0.10.0/24',
|
'--pool-prefix', '10.0.10.0/24',
|
||||||
"--project", identity_fakes_v3.project_name,
|
"--project", self.project.name,
|
||||||
"--project-domain", identity_fakes_v3.domain_name,
|
"--project-domain", self.domain.name,
|
||||||
self._subnet_pool.name,
|
self._subnet_pool.name,
|
||||||
]
|
]
|
||||||
verifylist = [
|
verifylist = [
|
||||||
('prefixes', ['10.0.10.0/24']),
|
('prefixes', ['10.0.10.0/24']),
|
||||||
('project', identity_fakes_v3.project_name),
|
('project', self.project.name),
|
||||||
('project_domain', identity_fakes_v3.domain_name),
|
('project_domain', self.domain.name),
|
||||||
('name', self._subnet_pool.name),
|
('name', self._subnet_pool.name),
|
||||||
]
|
]
|
||||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||||
@ -207,7 +200,7 @@ class TestCreateSubnetPool(TestSubnetPool):
|
|||||||
|
|
||||||
self.network.create_subnet_pool.assert_called_once_with(**{
|
self.network.create_subnet_pool.assert_called_once_with(**{
|
||||||
'prefixes': ['10.0.10.0/24'],
|
'prefixes': ['10.0.10.0/24'],
|
||||||
'tenant_id': identity_fakes_v3.project_id,
|
'tenant_id': self.project.id,
|
||||||
'name': self._subnet_pool.name,
|
'name': self._subnet_pool.name,
|
||||||
})
|
})
|
||||||
self.assertEqual(self.columns, columns)
|
self.assertEqual(self.columns, columns)
|
||||||
|
Loading…
Reference in New Issue
Block a user