def test_create_portgroups_no_ports(self, mock_create_ports): portgroup = {'name': 'fake'} portgroup_posted = {'name': 'fake', 'node_uuid': 'fake-node-uuid'} self.client.portgroup.create.return_value = mock.Mock(uuid='uuid') self.assertEqual([], create_resources.create_portgroups( self.client, [portgroup], node_uuid='fake-node-uuid')) self.client.portgroup.create.assert_called_once_with( **portgroup_posted) self.assertFalse(mock_create_ports.called)
def test_create_portgroups_two_node_uuids(self, mock_create_ports): portgroup = {'name': 'fake', 'node_uuid': 'fake-node-uuid-1', 'ports': ['list of ports']} self.client.portgroup.create.side_effect = exc.ClientException('bar') errs = create_resources.create_portgroups( self.client, [portgroup], node_uuid='fake-node-uuid-2') self.assertFalse(self.client.portgroup.create.called) self.assertFalse(mock_create_ports.called) self.assertEqual(1, len(errs)) self.assertIsInstance(errs[0], exc.ClientException)
def test_create_portgroups_no_ports(self, mock_create_ports): portgroup = {'name': 'fake'} portgroup_posted = {'name': 'fake', 'node_uuid': 'fake-node-uuid'} self.client.portgroup.create.return_value = mock.Mock(uuid='uuid') self.assertEqual([], create_resources.create_portgroups( self.client, [portgroup], node_uuid='fake-node-uuid')) self.client.portgroup.create.assert_called_once_with( **portgroup_posted) self.assertFalse(mock_create_ports.called)
def test_create_portgroups_exception(self, mock_create_ports): portgroup = {'name': 'fake', 'ports': ['list of ports']} portgroup_posted = {'name': 'fake', 'node_uuid': 'fake-node-uuid'} self.client.portgroup.create.side_effect = exc.ClientException('bar') errs = create_resources.create_portgroups(self.client, [portgroup], node_uuid='fake-node-uuid') self.client.portgroup.create.assert_called_once_with( **portgroup_posted) self.assertFalse(mock_create_ports.called) self.assertEqual(1, len(errs)) self.assertIsInstance(errs[0], exc.ClientException)