begin_unit
comment|'# Copyright 2012 SINA Inc.'
nl|'\n'
comment|'# All Rights Reserved.'
nl|'\n'
comment|'#'
nl|'\n'
comment|'#    Licensed under the Apache License, Version 2.0 (the "License"); you may'
nl|'\n'
comment|'#    not use this file except in compliance with the License. You may obtain'
nl|'\n'
comment|'#    a copy of the License at'
nl|'\n'
comment|'#'
nl|'\n'
comment|'#         http://www.apache.org/licenses/LICENSE-2.0'
nl|'\n'
comment|'#'
nl|'\n'
comment|'#    Unless required by applicable law or agreed to in writing, software'
nl|'\n'
comment|'#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT'
nl|'\n'
comment|'#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the'
nl|'\n'
comment|'#    License for the specific language governing permissions and limitations'
nl|'\n'
comment|'#    under the License.'
nl|'\n'
nl|'\n'
name|'import'
name|'mock'
newline|'\n'
nl|'\n'
name|'from'
name|'nova'
op|'.'
name|'api'
op|'.'
name|'openstack'
op|'.'
name|'compute'
name|'import'
name|'attach_interfaces'
name|'as'
name|'attach_interfaces_v21'
newline|'\n'
name|'from'
name|'nova'
op|'.'
name|'compute'
name|'import'
name|'api'
name|'as'
name|'compute_api'
newline|'\n'
name|'from'
name|'nova'
name|'import'
name|'exception'
newline|'\n'
name|'from'
name|'nova'
op|'.'
name|'network'
name|'import'
name|'api'
name|'as'
name|'network_api'
newline|'\n'
name|'from'
name|'nova'
name|'import'
name|'objects'
newline|'\n'
name|'from'
name|'nova'
name|'import'
name|'test'
newline|'\n'
name|'from'
name|'nova'
op|'.'
name|'tests'
op|'.'
name|'unit'
op|'.'
name|'api'
op|'.'
name|'openstack'
name|'import'
name|'fakes'
newline|'\n'
name|'from'
name|'nova'
op|'.'
name|'tests'
op|'.'
name|'unit'
name|'import'
name|'fake_network_cache_model'
newline|'\n'
nl|'\n'
name|'from'
name|'webob'
name|'import'
name|'exc'
newline|'\n'
nl|'\n'
nl|'\n'
DECL|variable|FAKE_UUID1
name|'FAKE_UUID1'
op|'='
string|"'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa'"
newline|'\n'
DECL|variable|FAKE_UUID2
name|'FAKE_UUID2'
op|'='
string|"'bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb'"
newline|'\n'
nl|'\n'
DECL|variable|FAKE_PORT_ID1
name|'FAKE_PORT_ID1'
op|'='
string|"'11111111-1111-1111-1111-111111111111'"
newline|'\n'
DECL|variable|FAKE_PORT_ID2
name|'FAKE_PORT_ID2'
op|'='
string|"'22222222-2222-2222-2222-222222222222'"
newline|'\n'
DECL|variable|FAKE_PORT_ID3
name|'FAKE_PORT_ID3'
op|'='
string|"'33333333-3333-3333-3333-333333333333'"
newline|'\n'
DECL|variable|FAKE_NOT_FOUND_PORT_ID
name|'FAKE_NOT_FOUND_PORT_ID'
op|'='
string|"'00000000-0000-0000-0000-000000000000'"
newline|'\n'
nl|'\n'
DECL|variable|FAKE_NET_ID1
name|'FAKE_NET_ID1'
op|'='
string|"'44444444-4444-4444-4444-444444444444'"
newline|'\n'
DECL|variable|FAKE_NET_ID2
name|'FAKE_NET_ID2'
op|'='
string|"'55555555-5555-5555-5555-555555555555'"
newline|'\n'
DECL|variable|FAKE_NET_ID3
name|'FAKE_NET_ID3'
op|'='
string|"'66666666-6666-6666-6666-666666666666'"
newline|'\n'
DECL|variable|FAKE_BAD_NET_ID
name|'FAKE_BAD_NET_ID'
op|'='
string|"'00000000-0000-0000-0000-000000000000'"
newline|'\n'
nl|'\n'
DECL|variable|port_data1
name|'port_data1'
op|'='
op|'{'
nl|'\n'
string|'"id"'
op|':'
name|'FAKE_PORT_ID1'
op|','
nl|'\n'
string|'"network_id"'
op|':'
name|'FAKE_NET_ID1'
op|','
nl|'\n'
string|'"admin_state_up"'
op|':'
name|'True'
op|','
nl|'\n'
string|'"status"'
op|':'
string|'"ACTIVE"'
op|','
nl|'\n'
string|'"mac_address"'
op|':'
string|'"aa:aa:aa:aa:aa:aa"'
op|','
nl|'\n'
string|'"fixed_ips"'
op|':'
op|'['
string|'"10.0.1.2"'
op|']'
op|','
nl|'\n'
string|'"device_id"'
op|':'
name|'FAKE_UUID1'
op|','
nl|'\n'
op|'}'
newline|'\n'
nl|'\n'
DECL|variable|port_data2
name|'port_data2'
op|'='
op|'{'
nl|'\n'
string|'"id"'
op|':'
name|'FAKE_PORT_ID2'
op|','
nl|'\n'
string|'"network_id"'
op|':'
name|'FAKE_NET_ID2'
op|','
nl|'\n'
string|'"admin_state_up"'
op|':'
name|'True'
op|','
nl|'\n'
string|'"status"'
op|':'
string|'"ACTIVE"'
op|','
nl|'\n'
string|'"mac_address"'
op|':'
string|'"bb:bb:bb:bb:bb:bb"'
op|','
nl|'\n'
string|'"fixed_ips"'
op|':'
op|'['
string|'"10.0.2.2"'
op|']'
op|','
nl|'\n'
string|'"device_id"'
op|':'
name|'FAKE_UUID1'
op|','
nl|'\n'
op|'}'
newline|'\n'
nl|'\n'
DECL|variable|port_data3
name|'port_data3'
op|'='
op|'{'
nl|'\n'
string|'"id"'
op|':'
name|'FAKE_PORT_ID3'
op|','
nl|'\n'
string|'"network_id"'
op|':'
name|'FAKE_NET_ID3'
op|','
nl|'\n'
string|'"admin_state_up"'
op|':'
name|'True'
op|','
nl|'\n'
string|'"status"'
op|':'
string|'"ACTIVE"'
op|','
nl|'\n'
string|'"mac_address"'
op|':'
string|'"bb:bb:bb:bb:bb:bb"'
op|','
nl|'\n'
string|'"fixed_ips"'
op|':'
op|'['
string|'"10.0.2.2"'
op|']'
op|','
nl|'\n'
string|'"device_id"'
op|':'
string|"''"
op|','
nl|'\n'
op|'}'
newline|'\n'
nl|'\n'
DECL|variable|fake_networks
name|'fake_networks'
op|'='
op|'['
name|'FAKE_NET_ID1'
op|','
name|'FAKE_NET_ID2'
op|']'
newline|'\n'
DECL|variable|ports
name|'ports'
op|'='
op|'['
name|'port_data1'
op|','
name|'port_data2'
op|','
name|'port_data3'
op|']'
newline|'\n'
nl|'\n'
nl|'\n'
DECL|function|fake_list_ports
name|'def'
name|'fake_list_ports'
op|'('
name|'self'
op|','
op|'*'
name|'args'
op|','
op|'**'
name|'kwargs'
op|')'
op|':'
newline|'\n'
indent|'    '
name|'result'
op|'='
op|'['
op|']'
newline|'\n'
name|'for'
name|'port'
name|'in'
name|'ports'
op|':'
newline|'\n'
indent|'        '
name|'if'
name|'port'
op|'['
string|"'device_id'"
op|']'
op|'=='
name|'kwargs'
op|'['
string|"'device_id'"
op|']'
op|':'
newline|'\n'
indent|'            '
name|'result'
op|'.'
name|'append'
op|'('
name|'port'
op|')'
newline|'\n'
dedent|''
dedent|''
name|'return'
op|'{'
string|"'ports'"
op|':'
name|'result'
op|'}'
newline|'\n'
nl|'\n'
nl|'\n'
DECL|function|fake_show_port
dedent|''
name|'def'
name|'fake_show_port'
op|'('
name|'self'
op|','
name|'context'
op|','
name|'port_id'
op|','
op|'**'
name|'kwargs'
op|')'
op|':'
newline|'\n'
indent|'    '
name|'for'
name|'port'
name|'in'
name|'ports'
op|':'
newline|'\n'
indent|'        '
name|'if'
name|'port'
op|'['
string|"'id'"
op|']'
op|'=='
name|'port_id'
op|':'
newline|'\n'
indent|'            '
name|'return'
op|'{'
string|"'port'"
op|':'
name|'port'
op|'}'
newline|'\n'
dedent|''
dedent|''
name|'else'
op|':'
newline|'\n'
indent|'        '
name|'raise'
name|'exception'
op|'.'
name|'PortNotFound'
op|'('
name|'port_id'
op|'='
name|'port_id'
op|')'
newline|'\n'
nl|'\n'
nl|'\n'
DECL|function|fake_attach_interface
dedent|''
dedent|''
name|'def'
name|'fake_attach_interface'
op|'('
name|'self'
op|','
name|'context'
op|','
name|'instance'
op|','
name|'network_id'
op|','
name|'port_id'
op|','
nl|'\n'
name|'requested_ip'
op|'='
string|"'192.168.1.3'"
op|')'
op|':'
newline|'\n'
indent|'    '
name|'if'
name|'not'
name|'network_id'
op|':'
newline|'\n'
comment|'# if no network_id is given when add a port to an instance, use the'
nl|'\n'
comment|'# first default network.'
nl|'\n'
indent|'        '
name|'network_id'
op|'='
name|'fake_networks'
op|'['
number|'0'
op|']'
newline|'\n'
dedent|''
name|'if'
name|'network_id'
op|'=='
name|'FAKE_BAD_NET_ID'
op|':'
newline|'\n'
indent|'        '
name|'raise'
name|'exception'
op|'.'
name|'NetworkNotFound'
op|'('
name|'network_id'
op|'='
name|'network_id'
op|')'
newline|'\n'
dedent|''
name|'if'
name|'not'
name|'port_id'
op|':'
newline|'\n'
indent|'        '
name|'port_id'
op|'='
name|'ports'
op|'['
name|'fake_networks'
op|'.'
name|'index'
op|'('
name|'network_id'
op|')'
op|']'
op|'['
string|"'id'"
op|']'
newline|'\n'
dedent|''
name|'if'
name|'port_id'
op|'=='
name|'FAKE_NOT_FOUND_PORT_ID'
op|':'
newline|'\n'
indent|'        '
name|'raise'
name|'exception'
op|'.'
name|'PortNotFound'
op|'('
name|'port_id'
op|'='
name|'port_id'
op|')'
newline|'\n'
dedent|''
name|'vif'
op|'='
name|'fake_network_cache_model'
op|'.'
name|'new_vif'
op|'('
op|')'
newline|'\n'
name|'vif'
op|'['
string|"'id'"
op|']'
op|'='
name|'port_id'
newline|'\n'
name|'vif'
op|'['
string|"'network'"
op|']'
op|'['
string|"'id'"
op|']'
op|'='
name|'network_id'
newline|'\n'
name|'vif'
op|'['
string|"'network'"
op|']'
op|'['
string|"'subnets'"
op|']'
op|'['
number|'0'
op|']'
op|'['
string|"'ips'"
op|']'
op|'['
number|'0'
op|']'
op|'['
string|"'address'"
op|']'
op|'='
name|'requested_ip'
newline|'\n'
name|'return'
name|'vif'
newline|'\n'
nl|'\n'
nl|'\n'
DECL|function|fake_detach_interface
dedent|''
name|'def'
name|'fake_detach_interface'
op|'('
name|'self'
op|','
name|'context'
op|','
name|'instance'
op|','
name|'port_id'
op|')'
op|':'
newline|'\n'
indent|'    '
name|'for'
name|'port'
name|'in'
name|'ports'
op|':'
newline|'\n'
indent|'        '
name|'if'
name|'port'
op|'['
string|"'id'"
op|']'
op|'=='
name|'port_id'
op|':'
newline|'\n'
indent|'            '
name|'return'
newline|'\n'
dedent|''
dedent|''
name|'raise'
name|'exception'
op|'.'
name|'PortNotFound'
op|'('
name|'port_id'
op|'='
name|'port_id'
op|')'
newline|'\n'
nl|'\n'
nl|'\n'
DECL|function|fake_get_instance
dedent|''
name|'def'
name|'fake_get_instance'
op|'('
name|'self'
op|','
op|'*'
name|'args'
op|','
op|'**'
name|'kwargs'
op|')'
op|':'
newline|'\n'
indent|'    '
name|'return'
name|'objects'
op|'.'
name|'Instance'
op|'('
name|'uuid'
op|'='
name|'FAKE_UUID1'
op|')'
newline|'\n'
nl|'\n'
nl|'\n'
DECL|class|InterfaceAttachTestsV21
dedent|''
name|'class'
name|'InterfaceAttachTestsV21'
op|'('
name|'test'
op|'.'
name|'NoDBTestCase'
op|')'
op|':'
newline|'\n'
DECL|variable|controller_cls
indent|'    '
name|'controller_cls'
op|'='
name|'attach_interfaces_v21'
op|'.'
name|'InterfaceAttachmentController'
newline|'\n'
DECL|variable|validate_exc
name|'validate_exc'
op|'='
name|'exception'
op|'.'
name|'ValidationError'
newline|'\n'
DECL|variable|in_use_exc
name|'in_use_exc'
op|'='
name|'exc'
op|'.'
name|'HTTPConflict'
newline|'\n'
DECL|variable|not_found_exc
name|'not_found_exc'
op|'='
name|'exc'
op|'.'
name|'HTTPNotFound'
newline|'\n'
DECL|variable|not_usable_exc
name|'not_usable_exc'
op|'='
name|'exc'
op|'.'
name|'HTTPBadRequest'
newline|'\n'
nl|'\n'
DECL|member|setUp
name|'def'
name|'setUp'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'super'
op|'('
name|'InterfaceAttachTestsV21'
op|','
name|'self'
op|')'
op|'.'
name|'setUp'
op|'('
op|')'
newline|'\n'
name|'self'
op|'.'
name|'flags'
op|'('
name|'timeout'
op|'='
number|'30'
op|','
name|'group'
op|'='
string|"'neutron'"
op|')'
newline|'\n'
name|'self'
op|'.'
name|'stubs'
op|'.'
name|'Set'
op|'('
name|'network_api'
op|'.'
name|'API'
op|','
string|"'show_port'"
op|','
name|'fake_show_port'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'stubs'
op|'.'
name|'Set'
op|'('
name|'network_api'
op|'.'
name|'API'
op|','
string|"'list_ports'"
op|','
name|'fake_list_ports'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'stubs'
op|'.'
name|'Set'
op|'('
name|'compute_api'
op|'.'
name|'API'
op|','
string|"'get'"
op|','
name|'fake_get_instance'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'expected_show'
op|'='
op|'{'
string|"'interfaceAttachment'"
op|':'
nl|'\n'
op|'{'
string|"'net_id'"
op|':'
name|'FAKE_NET_ID1'
op|','
nl|'\n'
string|"'port_id'"
op|':'
name|'FAKE_PORT_ID1'
op|','
nl|'\n'
string|"'mac_addr'"
op|':'
name|'port_data1'
op|'['
string|"'mac_address'"
op|']'
op|','
nl|'\n'
string|"'port_state'"
op|':'
name|'port_data1'
op|'['
string|"'status'"
op|']'
op|','
nl|'\n'
string|"'fixed_ips'"
op|':'
name|'port_data1'
op|'['
string|"'fixed_ips'"
op|']'
op|','
nl|'\n'
op|'}'
op|'}'
newline|'\n'
name|'self'
op|'.'
name|'attachments'
op|'='
name|'self'
op|'.'
name|'controller_cls'
op|'('
op|')'
newline|'\n'
name|'self'
op|'.'
name|'req'
op|'='
name|'fakes'
op|'.'
name|'HTTPRequest'
op|'.'
name|'blank'
op|'('
string|"''"
op|')'
newline|'\n'
nl|'\n'
dedent|''
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'.'
name|'object'
op|'('
name|'compute_api'
op|'.'
name|'API'
op|','
string|"'get'"
op|','
nl|'\n'
name|'side_effect'
op|'='
name|'exception'
op|'.'
name|'InstanceNotFound'
op|'('
name|'instance_id'
op|'='
string|"''"
op|')'
op|')'
newline|'\n'
DECL|member|_test_instance_not_found
name|'def'
name|'_test_instance_not_found'
op|'('
name|'self'
op|','
name|'func'
op|','
name|'args'
op|','
name|'mock_get'
op|','
name|'kwargs'
op|'='
name|'None'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'if'
name|'not'
name|'kwargs'
op|':'
newline|'\n'
indent|'            '
name|'kwargs'
op|'='
op|'{'
op|'}'
newline|'\n'
dedent|''
name|'self'
op|'.'
name|'assertRaises'
op|'('
name|'exc'
op|'.'
name|'HTTPNotFound'
op|','
name|'func'
op|','
name|'self'
op|'.'
name|'req'
op|','
op|'*'
name|'args'
op|','
op|'**'
name|'kwargs'
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_show_instance_not_found
dedent|''
name|'def'
name|'test_show_instance_not_found'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'self'
op|'.'
name|'_test_instance_not_found'
op|'('
name|'self'
op|'.'
name|'attachments'
op|'.'
name|'show'
op|','
op|'('
string|"'fake'"
op|','
string|"'fake'"
op|')'
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_index_instance_not_found
dedent|''
name|'def'
name|'test_index_instance_not_found'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'self'
op|'.'
name|'_test_instance_not_found'
op|'('
name|'self'
op|'.'
name|'attachments'
op|'.'
name|'index'
op|','
op|'('
string|"'fake'"
op|','
op|')'
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_detach_interface_instance_not_found
dedent|''
name|'def'
name|'test_detach_interface_instance_not_found'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'self'
op|'.'
name|'_test_instance_not_found'
op|'('
name|'self'
op|'.'
name|'attachments'
op|'.'
name|'delete'
op|','
nl|'\n'
op|'('
string|"'fake'"
op|','
string|"'fake'"
op|')'
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_attach_interface_instance_not_found
dedent|''
name|'def'
name|'test_attach_interface_instance_not_found'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'self'
op|'.'
name|'_test_instance_not_found'
op|'('
name|'self'
op|'.'
name|'attachments'
op|'.'
name|'create'
op|','
op|'('
string|"'fake'"
op|','
op|')'
op|','
nl|'\n'
name|'kwargs'
op|'='
op|'{'
string|"'body'"
op|':'
op|'{'
string|"'interfaceAttachment'"
op|':'
op|'{'
op|'}'
op|'}'
op|'}'
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_show
dedent|''
name|'def'
name|'test_show'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'result'
op|'='
name|'self'
op|'.'
name|'attachments'
op|'.'
name|'show'
op|'('
name|'self'
op|'.'
name|'req'
op|','
name|'FAKE_UUID1'
op|','
name|'FAKE_PORT_ID1'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
name|'self'
op|'.'
name|'expected_show'
op|','
name|'result'
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_show_with_port_not_found
dedent|''
name|'def'
name|'test_show_with_port_not_found'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'self'
op|'.'
name|'assertRaises'
op|'('
name|'exc'
op|'.'
name|'HTTPNotFound'
op|','
nl|'\n'
name|'self'
op|'.'
name|'attachments'
op|'.'
name|'show'
op|','
name|'self'
op|'.'
name|'req'
op|','
name|'FAKE_UUID2'
op|','
nl|'\n'
name|'FAKE_PORT_ID1'
op|')'
newline|'\n'
nl|'\n'
dedent|''
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'.'
name|'object'
op|'('
name|'network_api'
op|'.'
name|'API'
op|','
string|"'show_port'"
op|','
nl|'\n'
name|'side_effect'
op|'='
name|'exception'
op|'.'
name|'Forbidden'
op|')'
newline|'\n'
DECL|member|test_show_forbidden
name|'def'
name|'test_show_forbidden'
op|'('
name|'self'
op|','
name|'show_port_mock'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'self'
op|'.'
name|'assertRaises'
op|'('
name|'exc'
op|'.'
name|'HTTPForbidden'
op|','
nl|'\n'
name|'self'
op|'.'
name|'attachments'
op|'.'
name|'show'
op|','
name|'self'
op|'.'
name|'req'
op|','
name|'FAKE_UUID1'
op|','
nl|'\n'
name|'FAKE_PORT_ID1'
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_delete
dedent|''
name|'def'
name|'test_delete'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'self'
op|'.'
name|'stubs'
op|'.'
name|'Set'
op|'('
name|'compute_api'
op|'.'
name|'API'
op|','
string|"'detach_interface'"
op|','
nl|'\n'
name|'fake_detach_interface'
op|')'
newline|'\n'
nl|'\n'
name|'result'
op|'='
name|'self'
op|'.'
name|'attachments'
op|'.'
name|'delete'
op|'('
name|'self'
op|'.'
name|'req'
op|','
name|'FAKE_UUID1'
op|','
name|'FAKE_PORT_ID1'
op|')'
newline|'\n'
comment|'# NOTE: on v2.1, http status code is set as wsgi_code of API'
nl|'\n'
comment|'# method instead of status_int in a response object.'
nl|'\n'
name|'if'
name|'isinstance'
op|'('
name|'self'
op|'.'
name|'attachments'
op|','
nl|'\n'
name|'attach_interfaces_v21'
op|'.'
name|'InterfaceAttachmentController'
op|')'
op|':'
newline|'\n'
indent|'            '
name|'status_int'
op|'='
name|'self'
op|'.'
name|'attachments'
op|'.'
name|'delete'
op|'.'
name|'wsgi_code'
newline|'\n'
dedent|''
name|'else'
op|':'
newline|'\n'
indent|'            '
name|'status_int'
op|'='
name|'result'
op|'.'
name|'status_int'
newline|'\n'
dedent|''
name|'self'
op|'.'
name|'assertEqual'
op|'('
number|'202'
op|','
name|'status_int'
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_detach_interface_instance_locked
dedent|''
name|'def'
name|'test_detach_interface_instance_locked'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
DECL|function|fake_detach_interface_from_locked_server
indent|'        '
name|'def'
name|'fake_detach_interface_from_locked_server'
op|'('
name|'self'
op|','
name|'context'
op|','
nl|'\n'
name|'instance'
op|','
name|'port_id'
op|')'
op|':'
newline|'\n'
indent|'            '
name|'raise'
name|'exception'
op|'.'
name|'InstanceIsLocked'
op|'('
name|'instance_uuid'
op|'='
name|'FAKE_UUID1'
op|')'
newline|'\n'
nl|'\n'
dedent|''
name|'self'
op|'.'
name|'stubs'
op|'.'
name|'Set'
op|'('
name|'compute_api'
op|'.'
name|'API'
op|','
nl|'\n'
string|"'detach_interface'"
op|','
nl|'\n'
name|'fake_detach_interface_from_locked_server'
op|')'
newline|'\n'
nl|'\n'
name|'self'
op|'.'
name|'assertRaises'
op|'('
name|'exc'
op|'.'
name|'HTTPConflict'
op|','
nl|'\n'
name|'self'
op|'.'
name|'attachments'
op|'.'
name|'delete'
op|','
nl|'\n'
name|'self'
op|'.'
name|'req'
op|','
nl|'\n'
name|'FAKE_UUID1'
op|','
nl|'\n'
name|'FAKE_PORT_ID1'
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_delete_interface_not_found
dedent|''
name|'def'
name|'test_delete_interface_not_found'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'self'
op|'.'
name|'stubs'
op|'.'
name|'Set'
op|'('
name|'compute_api'
op|'.'
name|'API'
op|','
string|"'detach_interface'"
op|','
nl|'\n'
name|'fake_detach_interface'
op|')'
newline|'\n'
nl|'\n'
name|'self'
op|'.'
name|'assertRaises'
op|'('
name|'exc'
op|'.'
name|'HTTPNotFound'
op|','
nl|'\n'
name|'self'
op|'.'
name|'attachments'
op|'.'
name|'delete'
op|','
nl|'\n'
name|'self'
op|'.'
name|'req'
op|','
nl|'\n'
name|'FAKE_UUID1'
op|','
nl|'\n'
string|"'invaid-port-id'"
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_attach_interface_instance_locked
dedent|''
name|'def'
name|'test_attach_interface_instance_locked'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
DECL|function|fake_attach_interface_to_locked_server
indent|'        '
name|'def'
name|'fake_attach_interface_to_locked_server'
op|'('
name|'self'
op|','
name|'context'
op|','
nl|'\n'
name|'instance'
op|','
name|'network_id'
op|','
name|'port_id'
op|','
name|'requested_ip'
op|')'
op|':'
newline|'\n'
indent|'            '
name|'raise'
name|'exception'
op|'.'
name|'InstanceIsLocked'
op|'('
name|'instance_uuid'
op|'='
name|'FAKE_UUID1'
op|')'
newline|'\n'
nl|'\n'
dedent|''
name|'self'
op|'.'
name|'stubs'
op|'.'
name|'Set'
op|'('
name|'compute_api'
op|'.'
name|'API'
op|','
nl|'\n'
string|"'attach_interface'"
op|','
nl|'\n'
name|'fake_attach_interface_to_locked_server'
op|')'
newline|'\n'
name|'body'
op|'='
op|'{'
op|'}'
newline|'\n'
name|'self'
op|'.'
name|'assertRaises'
op|'('
name|'exc'
op|'.'
name|'HTTPConflict'
op|','
nl|'\n'
name|'self'
op|'.'
name|'attachments'
op|'.'
name|'create'
op|','
name|'self'
op|'.'
name|'req'
op|','
name|'FAKE_UUID1'
op|','
nl|'\n'
name|'body'
op|'='
name|'body'
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_attach_interface_without_network_id
dedent|''
name|'def'
name|'test_attach_interface_without_network_id'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'self'
op|'.'
name|'stubs'
op|'.'
name|'Set'
op|'('
name|'compute_api'
op|'.'
name|'API'
op|','
string|"'attach_interface'"
op|','
nl|'\n'
name|'fake_attach_interface'
op|')'
newline|'\n'
name|'body'
op|'='
op|'{'
op|'}'
newline|'\n'
name|'result'
op|'='
name|'self'
op|'.'
name|'attachments'
op|'.'
name|'create'
op|'('
name|'self'
op|'.'
name|'req'
op|','
name|'FAKE_UUID1'
op|','
name|'body'
op|'='
name|'body'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
name|'result'
op|'['
string|"'interfaceAttachment'"
op|']'
op|'['
string|"'net_id'"
op|']'
op|','
nl|'\n'
name|'FAKE_NET_ID1'
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_attach_interface_with_network_id
dedent|''
name|'def'
name|'test_attach_interface_with_network_id'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'self'
op|'.'
name|'stubs'
op|'.'
name|'Set'
op|'('
name|'compute_api'
op|'.'
name|'API'
op|','
string|"'attach_interface'"
op|','
nl|'\n'
name|'fake_attach_interface'
op|')'
newline|'\n'
name|'body'
op|'='
op|'{'
string|"'interfaceAttachment'"
op|':'
op|'{'
string|"'net_id'"
op|':'
name|'FAKE_NET_ID2'
op|'}'
op|'}'
newline|'\n'
name|'result'
op|'='
name|'self'
op|'.'
name|'attachments'
op|'.'
name|'create'
op|'('
name|'self'
op|'.'
name|'req'
op|','
name|'FAKE_UUID1'
op|','
name|'body'
op|'='
name|'body'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
name|'result'
op|'['
string|"'interfaceAttachment'"
op|']'
op|'['
string|"'net_id'"
op|']'
op|','
nl|'\n'
name|'FAKE_NET_ID2'
op|')'
newline|'\n'
nl|'\n'
DECL|member|_attach_interface_bad_request_case
dedent|''
name|'def'
name|'_attach_interface_bad_request_case'
op|'('
name|'self'
op|','
name|'body'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'self'
op|'.'
name|'stubs'
op|'.'
name|'Set'
op|'('
name|'compute_api'
op|'.'
name|'API'
op|','
string|"'attach_interface'"
op|','
nl|'\n'
name|'fake_attach_interface'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertRaises'
op|'('
name|'exc'
op|'.'
name|'HTTPBadRequest'
op|','
nl|'\n'
name|'self'
op|'.'
name|'attachments'
op|'.'
name|'create'
op|','
name|'self'
op|'.'
name|'req'
op|','
name|'FAKE_UUID1'
op|','
nl|'\n'
name|'body'
op|'='
name|'body'
op|')'
newline|'\n'
nl|'\n'
DECL|member|_attach_interface_not_found_case
dedent|''
name|'def'
name|'_attach_interface_not_found_case'
op|'('
name|'self'
op|','
name|'body'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'self'
op|'.'
name|'stubs'
op|'.'
name|'Set'
op|'('
name|'compute_api'
op|'.'
name|'API'
op|','
string|"'attach_interface'"
op|','
nl|'\n'
name|'fake_attach_interface'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertRaises'
op|'('
name|'self'
op|'.'
name|'not_found_exc'
op|','
nl|'\n'
name|'self'
op|'.'
name|'attachments'
op|'.'
name|'create'
op|','
name|'self'
op|'.'
name|'req'
op|','
name|'FAKE_UUID1'
op|','
nl|'\n'
name|'body'
op|'='
name|'body'
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_attach_interface_with_port_and_network_id
dedent|''
name|'def'
name|'test_attach_interface_with_port_and_network_id'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'body'
op|'='
op|'{'
nl|'\n'
string|"'interfaceAttachment'"
op|':'
op|'{'
nl|'\n'
string|"'port_id'"
op|':'
name|'FAKE_PORT_ID1'
op|','
nl|'\n'
string|"'net_id'"
op|':'
name|'FAKE_NET_ID2'
nl|'\n'
op|'}'
nl|'\n'
op|'}'
newline|'\n'
name|'self'
op|'.'
name|'_attach_interface_bad_request_case'
op|'('
name|'body'
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_attach_interface_with_not_found_network_id
dedent|''
name|'def'
name|'test_attach_interface_with_not_found_network_id'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'body'
op|'='
op|'{'
nl|'\n'
string|"'interfaceAttachment'"
op|':'
op|'{'
nl|'\n'
string|"'net_id'"
op|':'
name|'FAKE_BAD_NET_ID'
nl|'\n'
op|'}'
nl|'\n'
op|'}'
newline|'\n'
name|'self'
op|'.'
name|'_attach_interface_not_found_case'
op|'('
name|'body'
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_attach_interface_with_not_found_port_id
dedent|''
name|'def'
name|'test_attach_interface_with_not_found_port_id'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'body'
op|'='
op|'{'
nl|'\n'
string|"'interfaceAttachment'"
op|':'
op|'{'
nl|'\n'
string|"'port_id'"
op|':'
name|'FAKE_NOT_FOUND_PORT_ID'
nl|'\n'
op|'}'
nl|'\n'
op|'}'
newline|'\n'
name|'self'
op|'.'
name|'_attach_interface_not_found_case'
op|'('
name|'body'
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_attach_interface_with_invalid_state
dedent|''
name|'def'
name|'test_attach_interface_with_invalid_state'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
DECL|function|fake_attach_interface_invalid_state
indent|'        '
name|'def'
name|'fake_attach_interface_invalid_state'
op|'('
op|'*'
name|'args'
op|','
op|'**'
name|'kwargs'
op|')'
op|':'
newline|'\n'
indent|'            '
name|'raise'
name|'exception'
op|'.'
name|'InstanceInvalidState'
op|'('
nl|'\n'
name|'instance_uuid'
op|'='
string|"''"
op|','
name|'attr'
op|'='
string|"''"
op|','
name|'state'
op|'='
string|"''"
op|','
nl|'\n'
name|'method'
op|'='
string|"'attach_interface'"
op|')'
newline|'\n'
nl|'\n'
dedent|''
name|'self'
op|'.'
name|'stubs'
op|'.'
name|'Set'
op|'('
name|'compute_api'
op|'.'
name|'API'
op|','
string|"'attach_interface'"
op|','
nl|'\n'
name|'fake_attach_interface_invalid_state'
op|')'
newline|'\n'
name|'body'
op|'='
op|'{'
string|"'interfaceAttachment'"
op|':'
op|'{'
string|"'net_id'"
op|':'
name|'FAKE_NET_ID1'
op|'}'
op|'}'
newline|'\n'
name|'self'
op|'.'
name|'assertRaises'
op|'('
name|'exc'
op|'.'
name|'HTTPConflict'
op|','
nl|'\n'
name|'self'
op|'.'
name|'attachments'
op|'.'
name|'create'
op|','
name|'self'
op|'.'
name|'req'
op|','
name|'FAKE_UUID1'
op|','
nl|'\n'
name|'body'
op|'='
name|'body'
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_detach_interface_with_invalid_state
dedent|''
name|'def'
name|'test_detach_interface_with_invalid_state'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
DECL|function|fake_detach_interface_invalid_state
indent|'        '
name|'def'
name|'fake_detach_interface_invalid_state'
op|'('
op|'*'
name|'args'
op|','
op|'**'
name|'kwargs'
op|')'
op|':'
newline|'\n'
indent|'            '
name|'raise'
name|'exception'
op|'.'
name|'InstanceInvalidState'
op|'('
nl|'\n'
name|'instance_uuid'
op|'='
string|"''"
op|','
name|'attr'
op|'='
string|"''"
op|','
name|'state'
op|'='
string|"''"
op|','
nl|'\n'
name|'method'
op|'='
string|"'detach_interface'"
op|')'
newline|'\n'
nl|'\n'
dedent|''
name|'self'
op|'.'
name|'stubs'
op|'.'
name|'Set'
op|'('
name|'compute_api'
op|'.'
name|'API'
op|','
string|"'detach_interface'"
op|','
nl|'\n'
name|'fake_detach_interface_invalid_state'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertRaises'
op|'('
name|'exc'
op|'.'
name|'HTTPConflict'
op|','
nl|'\n'
name|'self'
op|'.'
name|'attachments'
op|'.'
name|'delete'
op|','
nl|'\n'
name|'self'
op|'.'
name|'req'
op|','
nl|'\n'
name|'FAKE_UUID1'
op|','
nl|'\n'
name|'FAKE_NET_ID1'
op|')'
newline|'\n'
nl|'\n'
dedent|''
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'.'
name|'object'
op|'('
name|'compute_api'
op|'.'
name|'API'
op|','
string|"'detach_interface'"
op|','
nl|'\n'
name|'side_effect'
op|'='
name|'NotImplementedError'
op|'('
op|')'
op|')'
newline|'\n'
DECL|member|test_detach_interface_with_not_implemented
name|'def'
name|'test_detach_interface_with_not_implemented'
op|'('
name|'self'
op|','
name|'_mock'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'self'
op|'.'
name|'assertRaises'
op|'('
name|'exc'
op|'.'
name|'HTTPNotImplemented'
op|','
nl|'\n'
name|'self'
op|'.'
name|'attachments'
op|'.'
name|'delete'
op|','
nl|'\n'
name|'self'
op|'.'
name|'req'
op|','
name|'FAKE_UUID1'
op|','
name|'FAKE_NET_ID1'
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_attach_interface_invalid_fixed_ip
dedent|''
name|'def'
name|'test_attach_interface_invalid_fixed_ip'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'body'
op|'='
op|'{'
nl|'\n'
string|"'interfaceAttachment'"
op|':'
op|'{'
nl|'\n'
string|"'net_id'"
op|':'
name|'FAKE_NET_ID1'
op|','
nl|'\n'
string|"'fixed_ips'"
op|':'
op|'['
op|'{'
string|"'ip_address'"
op|':'
string|"'invalid_ip'"
op|'}'
op|']'
nl|'\n'
op|'}'
nl|'\n'
op|'}'
newline|'\n'
name|'self'
op|'.'
name|'assertRaises'
op|'('
name|'self'
op|'.'
name|'validate_exc'
op|','
nl|'\n'
name|'self'
op|'.'
name|'attachments'
op|'.'
name|'create'
op|','
name|'self'
op|'.'
name|'req'
op|','
name|'FAKE_UUID1'
op|','
nl|'\n'
name|'body'
op|'='
name|'body'
op|')'
newline|'\n'
nl|'\n'
dedent|''
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'.'
name|'object'
op|'('
name|'compute_api'
op|'.'
name|'API'
op|','
string|"'get'"
op|')'
newline|'\n'
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'.'
name|'object'
op|'('
name|'compute_api'
op|'.'
name|'API'
op|','
string|"'attach_interface'"
op|')'
newline|'\n'
DECL|member|test_attach_interface_fixed_ip_already_in_use
name|'def'
name|'test_attach_interface_fixed_ip_already_in_use'
op|'('
name|'self'
op|','
nl|'\n'
name|'attach_mock'
op|','
nl|'\n'
name|'get_mock'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'fake_instance'
op|'='
name|'objects'
op|'.'
name|'Instance'
op|'('
name|'uuid'
op|'='
name|'FAKE_UUID1'
op|')'
newline|'\n'
name|'get_mock'
op|'.'
name|'return_value'
op|'='
name|'fake_instance'
newline|'\n'
name|'attach_mock'
op|'.'
name|'side_effect'
op|'='
name|'exception'
op|'.'
name|'FixedIpAlreadyInUse'
op|'('
nl|'\n'
name|'address'
op|'='
string|"'10.0.2.2'"
op|','
name|'instance_uuid'
op|'='
name|'FAKE_UUID1'
op|')'
newline|'\n'
name|'body'
op|'='
op|'{'
op|'}'
newline|'\n'
name|'self'
op|'.'
name|'assertRaises'
op|'('
name|'self'
op|'.'
name|'in_use_exc'
op|','
nl|'\n'
name|'self'
op|'.'
name|'attachments'
op|'.'
name|'create'
op|','
name|'self'
op|'.'
name|'req'
op|','
name|'FAKE_UUID1'
op|','
nl|'\n'
name|'body'
op|'='
name|'body'
op|')'
newline|'\n'
name|'ctxt'
op|'='
name|'self'
op|'.'
name|'req'
op|'.'
name|'environ'
op|'['
string|"'nova.context'"
op|']'
newline|'\n'
name|'attach_mock'
op|'.'
name|'assert_called_once_with'
op|'('
name|'ctxt'
op|','
name|'fake_instance'
op|','
name|'None'
op|','
nl|'\n'
name|'None'
op|','
name|'None'
op|')'
newline|'\n'
name|'get_mock'
op|'.'
name|'assert_called_once_with'
op|'('
name|'ctxt'
op|','
name|'FAKE_UUID1'
op|','
nl|'\n'
name|'want_objects'
op|'='
name|'True'
op|','
nl|'\n'
name|'expected_attrs'
op|'='
name|'None'
op|')'
newline|'\n'
nl|'\n'
dedent|''
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'.'
name|'object'
op|'('
name|'compute_api'
op|'.'
name|'API'
op|','
string|"'get'"
op|')'
newline|'\n'
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'.'
name|'object'
op|'('
name|'compute_api'
op|'.'
name|'API'
op|','
string|"'attach_interface'"
op|')'
newline|'\n'
DECL|member|test_attach_interface_port_in_use
name|'def'
name|'test_attach_interface_port_in_use'
op|'('
name|'self'
op|','
nl|'\n'
name|'attach_mock'
op|','
nl|'\n'
name|'get_mock'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'fake_instance'
op|'='
name|'objects'
op|'.'
name|'Instance'
op|'('
name|'uuid'
op|'='
name|'FAKE_UUID1'
op|')'
newline|'\n'
name|'get_mock'
op|'.'
name|'return_value'
op|'='
name|'fake_instance'
newline|'\n'
name|'attach_mock'
op|'.'
name|'side_effect'
op|'='
name|'exception'
op|'.'
name|'PortInUse'
op|'('
nl|'\n'
name|'port_id'
op|'='
name|'FAKE_PORT_ID1'
op|')'
newline|'\n'
name|'body'
op|'='
op|'{'
op|'}'
newline|'\n'
name|'self'
op|'.'
name|'assertRaises'
op|'('
name|'self'
op|'.'
name|'in_use_exc'
op|','
nl|'\n'
name|'self'
op|'.'
name|'attachments'
op|'.'
name|'create'
op|','
name|'self'
op|'.'
name|'req'
op|','
name|'FAKE_UUID1'
op|','
nl|'\n'
name|'body'
op|'='
name|'body'
op|')'
newline|'\n'
name|'ctxt'
op|'='
name|'self'
op|'.'
name|'req'
op|'.'
name|'environ'
op|'['
string|"'nova.context'"
op|']'
newline|'\n'
name|'attach_mock'
op|'.'
name|'assert_called_once_with'
op|'('
name|'ctxt'
op|','
name|'fake_instance'
op|','
name|'None'
op|','
nl|'\n'
name|'None'
op|','
name|'None'
op|')'
newline|'\n'
name|'get_mock'
op|'.'
name|'assert_called_once_with'
op|'('
name|'ctxt'
op|','
name|'FAKE_UUID1'
op|','
nl|'\n'
name|'want_objects'
op|'='
name|'True'
op|','
nl|'\n'
name|'expected_attrs'
op|'='
name|'None'
op|')'
newline|'\n'
nl|'\n'
dedent|''
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'.'
name|'object'
op|'('
name|'compute_api'
op|'.'
name|'API'
op|','
string|"'get'"
op|')'
newline|'\n'
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'.'
name|'object'
op|'('
name|'compute_api'
op|'.'
name|'API'
op|','
string|"'attach_interface'"
op|')'
newline|'\n'
DECL|member|test_attach_interface_port_not_usable
name|'def'
name|'test_attach_interface_port_not_usable'
op|'('
name|'self'
op|','
nl|'\n'
name|'attach_mock'
op|','
nl|'\n'
name|'get_mock'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'fake_instance'
op|'='
name|'objects'
op|'.'
name|'Instance'
op|'('
name|'uuid'
op|'='
name|'FAKE_UUID1'
op|')'
newline|'\n'
name|'get_mock'
op|'.'
name|'return_value'
op|'='
name|'fake_instance'
newline|'\n'
name|'attach_mock'
op|'.'
name|'side_effect'
op|'='
name|'exception'
op|'.'
name|'PortNotUsable'
op|'('
nl|'\n'
name|'port_id'
op|'='
name|'FAKE_PORT_ID1'
op|','
nl|'\n'
name|'instance'
op|'='
name|'fake_instance'
op|'.'
name|'uuid'
op|')'
newline|'\n'
name|'body'
op|'='
op|'{'
op|'}'
newline|'\n'
name|'self'
op|'.'
name|'assertRaises'
op|'('
name|'self'
op|'.'
name|'not_usable_exc'
op|','
nl|'\n'
name|'self'
op|'.'
name|'attachments'
op|'.'
name|'create'
op|','
name|'self'
op|'.'
name|'req'
op|','
name|'FAKE_UUID1'
op|','
nl|'\n'
name|'body'
op|'='
name|'body'
op|')'
newline|'\n'
name|'ctxt'
op|'='
name|'self'
op|'.'
name|'req'
op|'.'
name|'environ'
op|'['
string|"'nova.context'"
op|']'
newline|'\n'
name|'attach_mock'
op|'.'
name|'assert_called_once_with'
op|'('
name|'ctxt'
op|','
name|'fake_instance'
op|','
name|'None'
op|','
nl|'\n'
name|'None'
op|','
name|'None'
op|')'
newline|'\n'
name|'get_mock'
op|'.'
name|'assert_called_once_with'
op|'('
name|'ctxt'
op|','
name|'FAKE_UUID1'
op|','
nl|'\n'
name|'want_objects'
op|'='
name|'True'
op|','
nl|'\n'
name|'expected_attrs'
op|'='
name|'None'
op|')'
newline|'\n'
nl|'\n'
dedent|''
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'.'
name|'object'
op|'('
name|'compute_api'
op|'.'
name|'API'
op|','
string|"'get'"
op|')'
newline|'\n'
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'.'
name|'object'
op|'('
name|'compute_api'
op|'.'
name|'API'
op|','
string|"'attach_interface'"
op|')'
newline|'\n'
DECL|member|test_attach_interface_failed_no_network
name|'def'
name|'test_attach_interface_failed_no_network'
op|'('
name|'self'
op|','
name|'attach_mock'
op|','
name|'get_mock'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'fake_instance'
op|'='
name|'objects'
op|'.'
name|'Instance'
op|'('
name|'uuid'
op|'='
name|'FAKE_UUID1'
op|','
nl|'\n'
name|'project_id'
op|'='
name|'FAKE_UUID2'
op|')'
newline|'\n'
name|'get_mock'
op|'.'
name|'return_value'
op|'='
name|'fake_instance'
newline|'\n'
name|'attach_mock'
op|'.'
name|'side_effect'
op|'='
op|'('
nl|'\n'
name|'exception'
op|'.'
name|'InterfaceAttachFailedNoNetwork'
op|'('
name|'project_id'
op|'='
name|'FAKE_UUID2'
op|')'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertRaises'
op|'('
name|'exc'
op|'.'
name|'HTTPBadRequest'
op|','
name|'self'
op|'.'
name|'attachments'
op|'.'
name|'create'
op|','
nl|'\n'
name|'self'
op|'.'
name|'req'
op|','
name|'FAKE_UUID1'
op|','
name|'body'
op|'='
op|'{'
op|'}'
op|')'
newline|'\n'
name|'ctxt'
op|'='
name|'self'
op|'.'
name|'req'
op|'.'
name|'environ'
op|'['
string|"'nova.context'"
op|']'
newline|'\n'
name|'attach_mock'
op|'.'
name|'assert_called_once_with'
op|'('
name|'ctxt'
op|','
name|'fake_instance'
op|','
name|'None'
op|','
nl|'\n'
name|'None'
op|','
name|'None'
op|')'
newline|'\n'
name|'get_mock'
op|'.'
name|'assert_called_once_with'
op|'('
name|'ctxt'
op|','
name|'FAKE_UUID1'
op|','
nl|'\n'
name|'want_objects'
op|'='
name|'True'
op|','
nl|'\n'
name|'expected_attrs'
op|'='
name|'None'
op|')'
newline|'\n'
nl|'\n'
dedent|''
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'.'
name|'object'
op|'('
name|'compute_api'
op|'.'
name|'API'
op|','
string|"'get'"
op|')'
newline|'\n'
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'.'
name|'object'
op|'('
name|'compute_api'
op|'.'
name|'API'
op|','
string|"'attach_interface'"
op|')'
newline|'\n'
DECL|member|test_attach_interface_no_more_fixed_ips
name|'def'
name|'test_attach_interface_no_more_fixed_ips'
op|'('
name|'self'
op|','
nl|'\n'
name|'attach_mock'
op|','
nl|'\n'
name|'get_mock'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'fake_instance'
op|'='
name|'objects'
op|'.'
name|'Instance'
op|'('
name|'uuid'
op|'='
name|'FAKE_UUID1'
op|')'
newline|'\n'
name|'get_mock'
op|'.'
name|'return_value'
op|'='
name|'fake_instance'
newline|'\n'
name|'attach_mock'
op|'.'
name|'side_effect'
op|'='
name|'exception'
op|'.'
name|'NoMoreFixedIps'
op|'('
nl|'\n'
name|'net'
op|'='
name|'FAKE_NET_ID1'
op|')'
newline|'\n'
name|'body'
op|'='
op|'{'
op|'}'
newline|'\n'
name|'self'
op|'.'
name|'assertRaises'
op|'('
name|'exc'
op|'.'
name|'HTTPBadRequest'
op|','
nl|'\n'
name|'self'
op|'.'
name|'attachments'
op|'.'
name|'create'
op|','
name|'self'
op|'.'
name|'req'
op|','
name|'FAKE_UUID1'
op|','
nl|'\n'
name|'body'
op|'='
name|'body'
op|')'
newline|'\n'
name|'ctxt'
op|'='
name|'self'
op|'.'
name|'req'
op|'.'
name|'environ'
op|'['
string|"'nova.context'"
op|']'
newline|'\n'
name|'attach_mock'
op|'.'
name|'assert_called_once_with'
op|'('
name|'ctxt'
op|','
name|'fake_instance'
op|','
name|'None'
op|','
nl|'\n'
name|'None'
op|','
name|'None'
op|')'
newline|'\n'
name|'get_mock'
op|'.'
name|'assert_called_once_with'
op|'('
name|'ctxt'
op|','
name|'FAKE_UUID1'
op|','
nl|'\n'
name|'want_objects'
op|'='
name|'True'
op|','
nl|'\n'
name|'expected_attrs'
op|'='
name|'None'
op|')'
newline|'\n'
nl|'\n'
DECL|member|_test_attach_interface_with_invalid_parameter
dedent|''
name|'def'
name|'_test_attach_interface_with_invalid_parameter'
op|'('
name|'self'
op|','
name|'param'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'self'
op|'.'
name|'stubs'
op|'.'
name|'Set'
op|'('
name|'compute_api'
op|'.'
name|'API'
op|','
string|"'attach_interface'"
op|','
nl|'\n'
name|'fake_attach_interface'
op|')'
newline|'\n'
name|'body'
op|'='
op|'{'
string|"'interface_attachment'"
op|':'
name|'param'
op|'}'
newline|'\n'
name|'self'
op|'.'
name|'assertRaises'
op|'('
name|'exception'
op|'.'
name|'ValidationError'
op|','
nl|'\n'
name|'self'
op|'.'
name|'attachments'
op|'.'
name|'create'
op|','
name|'self'
op|'.'
name|'req'
op|','
name|'FAKE_UUID1'
op|','
nl|'\n'
name|'body'
op|'='
name|'body'
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_attach_interface_instance_with_non_uuid_net_id
dedent|''
name|'def'
name|'test_attach_interface_instance_with_non_uuid_net_id'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'param'
op|'='
op|'{'
string|"'net_id'"
op|':'
string|"'non_uuid'"
op|'}'
newline|'\n'
name|'self'
op|'.'
name|'_test_attach_interface_with_invalid_parameter'
op|'('
name|'param'
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_attach_interface_instance_with_non_uuid_port_id
dedent|''
name|'def'
name|'test_attach_interface_instance_with_non_uuid_port_id'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'param'
op|'='
op|'{'
string|"'port_id'"
op|':'
string|"'non_uuid'"
op|'}'
newline|'\n'
name|'self'
op|'.'
name|'_test_attach_interface_with_invalid_parameter'
op|'('
name|'param'
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_attach_interface_instance_with_non_array_fixed_ips
dedent|''
name|'def'
name|'test_attach_interface_instance_with_non_array_fixed_ips'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'param'
op|'='
op|'{'
string|"'fixed_ips'"
op|':'
string|"'non_array'"
op|'}'
newline|'\n'
name|'self'
op|'.'
name|'_test_attach_interface_with_invalid_parameter'
op|'('
name|'param'
op|')'
newline|'\n'
nl|'\n'
nl|'\n'
DECL|class|AttachInterfacesPolicyEnforcementv21
dedent|''
dedent|''
name|'class'
name|'AttachInterfacesPolicyEnforcementv21'
op|'('
name|'test'
op|'.'
name|'NoDBTestCase'
op|')'
op|':'
newline|'\n'
nl|'\n'
DECL|member|setUp
indent|'    '
name|'def'
name|'setUp'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'super'
op|'('
name|'AttachInterfacesPolicyEnforcementv21'
op|','
name|'self'
op|')'
op|'.'
name|'setUp'
op|'('
op|')'
newline|'\n'
name|'self'
op|'.'
name|'controller'
op|'='
name|'attach_interfaces_v21'
op|'.'
name|'InterfaceAttachmentController'
op|'('
op|')'
newline|'\n'
name|'self'
op|'.'
name|'req'
op|'='
name|'fakes'
op|'.'
name|'HTTPRequest'
op|'.'
name|'blank'
op|'('
string|"''"
op|')'
newline|'\n'
name|'self'
op|'.'
name|'rule_name'
op|'='
string|'"os_compute_api:os-attach-interfaces"'
newline|'\n'
name|'self'
op|'.'
name|'policy'
op|'.'
name|'set_rules'
op|'('
op|'{'
name|'self'
op|'.'
name|'rule_name'
op|':'
string|'"project:non_fake"'
op|'}'
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_index_attach_interfaces_policy_failed
dedent|''
name|'def'
name|'test_index_attach_interfaces_policy_failed'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'exc'
op|'='
name|'self'
op|'.'
name|'assertRaises'
op|'('
nl|'\n'
name|'exception'
op|'.'
name|'PolicyNotAuthorized'
op|','
nl|'\n'
name|'self'
op|'.'
name|'controller'
op|'.'
name|'index'
op|','
name|'self'
op|'.'
name|'req'
op|','
name|'fakes'
op|'.'
name|'FAKE_UUID'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
nl|'\n'
string|'"Policy doesn\'t allow %s to be performed."'
op|'%'
name|'self'
op|'.'
name|'rule_name'
op|','
nl|'\n'
name|'exc'
op|'.'
name|'format_message'
op|'('
op|')'
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_show_attach_interfaces_policy_failed
dedent|''
name|'def'
name|'test_show_attach_interfaces_policy_failed'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'exc'
op|'='
name|'self'
op|'.'
name|'assertRaises'
op|'('
nl|'\n'
name|'exception'
op|'.'
name|'PolicyNotAuthorized'
op|','
nl|'\n'
name|'self'
op|'.'
name|'controller'
op|'.'
name|'show'
op|','
name|'self'
op|'.'
name|'req'
op|','
name|'fakes'
op|'.'
name|'FAKE_UUID'
op|','
name|'FAKE_PORT_ID1'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
nl|'\n'
string|'"Policy doesn\'t allow %s to be performed."'
op|'%'
name|'self'
op|'.'
name|'rule_name'
op|','
nl|'\n'
name|'exc'
op|'.'
name|'format_message'
op|'('
op|')'
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_create_attach_interfaces_policy_failed
dedent|''
name|'def'
name|'test_create_attach_interfaces_policy_failed'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'exc'
op|'='
name|'self'
op|'.'
name|'assertRaises'
op|'('
nl|'\n'
name|'exception'
op|'.'
name|'PolicyNotAuthorized'
op|','
nl|'\n'
name|'self'
op|'.'
name|'controller'
op|'.'
name|'create'
op|','
name|'self'
op|'.'
name|'req'
op|','
name|'fakes'
op|'.'
name|'FAKE_UUID'
op|','
name|'body'
op|'='
op|'{'
op|'}'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
nl|'\n'
string|'"Policy doesn\'t allow %s to be performed."'
op|'%'
name|'self'
op|'.'
name|'rule_name'
op|','
nl|'\n'
name|'exc'
op|'.'
name|'format_message'
op|'('
op|')'
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_delete_attach_interfaces_policy_failed
dedent|''
name|'def'
name|'test_delete_attach_interfaces_policy_failed'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'exc'
op|'='
name|'self'
op|'.'
name|'assertRaises'
op|'('
nl|'\n'
name|'exception'
op|'.'
name|'PolicyNotAuthorized'
op|','
nl|'\n'
name|'self'
op|'.'
name|'controller'
op|'.'
name|'delete'
op|','
name|'self'
op|'.'
name|'req'
op|','
name|'fakes'
op|'.'
name|'FAKE_UUID'
op|','
name|'FAKE_PORT_ID1'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
nl|'\n'
string|'"Policy doesn\'t allow %s to be performed."'
op|'%'
name|'self'
op|'.'
name|'rule_name'
op|','
nl|'\n'
name|'exc'
op|'.'
name|'format_message'
op|'('
op|')'
op|')'
newline|'\n'
dedent|''
dedent|''
endmarker|''
end_unit

begin_unit
comment|'# Copyright 2012 SINA Inc.'
nl|'\n'
comment|'# All Rights Reserved.'
nl|'\n'
comment|'#'
nl|'\n'
comment|'#    Licensed under the Apache License, Version 2.0 (the "License"); you may'
nl|'\n'
comment|'#    not use this file except in compliance with the License. You may obtain'
nl|'\n'
comment|'#    a copy of the License at'
nl|'\n'
comment|'#'
nl|'\n'
comment|'#         http://www.apache.org/licenses/LICENSE-2.0'
nl|'\n'
comment|'#'
nl|'\n'
comment|'#    Unless required by applicable law or agreed to in writing, software'
nl|'\n'
comment|'#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT'
nl|'\n'
comment|'#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the'
nl|'\n'
comment|'#    License for the specific language governing permissions and limitations'
nl|'\n'
comment|'#    under the License.'
nl|'\n'
nl|'\n'
name|'import'
name|'mock'
newline|'\n'
nl|'\n'
name|'from'
name|'nova'
op|'.'
name|'api'
op|'.'
name|'openstack'
op|'.'
name|'compute'
name|'import'
name|'attach_interfaces'
name|'as'
name|'attach_interfaces_v21'
newline|'\n'
name|'from'
name|'nova'
op|'.'
name|'compute'
name|'import'
name|'api'
name|'as'
name|'compute_api'
newline|'\n'
name|'from'
name|'nova'
name|'import'
name|'exception'
newline|'\n'
name|'from'
name|'nova'
op|'.'
name|'network'
name|'import'
name|'api'
name|'as'
name|'network_api'
newline|'\n'
name|'from'
name|'nova'
name|'import'
name|'objects'
newline|'\n'
name|'from'
name|'nova'
name|'import'
name|'test'
newline|'\n'
name|'from'
name|'nova'
op|'.'
name|'tests'
op|'.'
name|'unit'
op|'.'
name|'api'
op|'.'
name|'openstack'
name|'import'
name|'fakes'
newline|'\n'
name|'from'
name|'nova'
op|'.'
name|'tests'
op|'.'
name|'unit'
name|'import'
name|'fake_network_cache_model'
newline|'\n'
nl|'\n'
name|'from'
name|'webob'
name|'import'
name|'exc'
newline|'\n'
nl|'\n'
nl|'\n'
DECL|variable|FAKE_UUID1
name|'FAKE_UUID1'
op|'='
string|"'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa'"
newline|'\n'
DECL|variable|FAKE_UUID2
name|'FAKE_UUID2'
op|'='
string|"'bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb'"
newline|'\n'
nl|'\n'
DECL|variable|FAKE_PORT_ID1
name|'FAKE_PORT_ID1'
op|'='
string|"'11111111-1111-1111-1111-111111111111'"
newline|'\n'
DECL|variable|FAKE_PORT_ID2
name|'FAKE_PORT_ID2'
op|'='
string|"'22222222-2222-2222-2222-222222222222'"
newline|'\n'
DECL|variable|FAKE_PORT_ID3
name|'FAKE_PORT_ID3'
op|'='
string|"'33333333-3333-3333-3333-333333333333'"
newline|'\n'
DECL|variable|FAKE_NOT_FOUND_PORT_ID
name|'FAKE_NOT_FOUND_PORT_ID'
op|'='
string|"'00000000-0000-0000-0000-000000000000'"
newline|'\n'
nl|'\n'
DECL|variable|FAKE_NET_ID1
name|'FAKE_NET_ID1'
op|'='
string|"'44444444-4444-4444-4444-444444444444'"
newline|'\n'
DECL|variable|FAKE_NET_ID2
name|'FAKE_NET_ID2'
op|'='
string|"'55555555-5555-5555-5555-555555555555'"
newline|'\n'
DECL|variable|FAKE_NET_ID3
name|'FAKE_NET_ID3'
op|'='
string|"'66666666-6666-6666-6666-666666666666'"
newline|'\n'
DECL|variable|FAKE_BAD_NET_ID
name|'FAKE_BAD_NET_ID'
op|'='
string|"'00000000-0000-0000-0000-000000000000'"
newline|'\n'
nl|'\n'
DECL|variable|port_data1
name|'port_data1'
op|'='
op|'{'
nl|'\n'
string|'"id"'
op|':'
name|'FAKE_PORT_ID1'
op|','
nl|'\n'
string|'"network_id"'
op|':'
name|'FAKE_NET_ID1'
op|','
nl|'\n'
string|'"admin_state_up"'
op|':'
name|'True'
op|','
nl|'\n'
string|'"status"'
op|':'
string|'"ACTIVE"'
op|','
nl|'\n'
string|'"mac_address"'
op|':'
string|'"aa:aa:aa:aa:aa:aa"'
op|','
nl|'\n'
string|'"fixed_ips"'
op|':'
op|'['
string|'"10.0.1.2"'
op|']'
op|','
nl|'\n'
string|'"device_id"'
op|':'
name|'FAKE_UUID1'
op|','
nl|'\n'
op|'}'
newline|'\n'
nl|'\n'
DECL|variable|port_data2
name|'port_data2'
op|'='
op|'{'
nl|'\n'
string|'"id"'
op|':'
name|'FAKE_PORT_ID2'
op|','
nl|'\n'
string|'"network_id"'
op|':'
name|'FAKE_NET_ID2'
op|','
nl|'\n'
string|'"admin_state_up"'
op|':'
name|'True'
op|','
nl|'\n'
string|'"status"'
op|':'
string|'"ACTIVE"'
op|','
nl|'\n'
string|'"mac_address"'
op|':'
string|'"bb:bb:bb:bb:bb:bb"'
op|','
nl|'\n'
string|'"fixed_ips"'
op|':'
op|'['
string|'"10.0.2.2"'
op|']'
op|','
nl|'\n'
string|'"device_id"'
op|':'
name|'FAKE_UUID1'
op|','
nl|'\n'
op|'}'
newline|'\n'
nl|'\n'
DECL|variable|port_data3
name|'port_data3'
op|'='
op|'{'
nl|'\n'
string|'"id"'
op|':'
name|'FAKE_PORT_ID3'
op|','
nl|'\n'
string|'"network_id"'
op|':'
name|'FAKE_NET_ID3'
op|','
nl|'\n'
string|'"admin_state_up"'
op|':'
name|'True'
op|','
nl|'\n'
string|'"status"'
op|':'
string|'"ACTIVE"'
op|','
nl|'\n'
string|'"mac_address"'
op|':'
string|'"bb:bb:bb:bb:bb:bb"'
op|','
nl|'\n'
string|'"fixed_ips"'
op|':'
op|'['
string|'"10.0.2.2"'
op|']'
op|','
nl|'\n'
string|'"device_id"'
op|':'
string|"''"
op|','
nl|'\n'
op|'}'
newline|'\n'
nl|'\n'
DECL|variable|fake_networks
name|'fake_networks'
op|'='
op|'['
name|'FAKE_NET_ID1'
op|','
name|'FAKE_NET_ID2'
op|']'
newline|'\n'
DECL|variable|ports
name|'ports'
op|'='
op|'['
name|'port_data1'
op|','
name|'port_data2'
op|','
name|'port_data3'
op|']'
newline|'\n'
nl|'\n'
nl|'\n'
DECL|function|fake_list_ports
name|'def'
name|'fake_list_ports'
op|'('
name|'self'
op|','
op|'*'
name|'args'
op|','
op|'**'
name|'kwargs'
op|')'
op|':'
newline|'\n'
indent|'    '
name|'result'
op|'='
op|'['
op|']'
newline|'\n'
name|'for'
name|'port'
name|'in'
name|'ports'
op|':'
newline|'\n'
indent|'        '
name|'if'
name|'port'
op|'['
string|"'device_id'"
op|']'
op|'=='
name|'kwargs'
op|'['
string|"'device_id'"
op|']'
op|':'
newline|'\n'
indent|'            '
name|'result'
op|'.'
name|'append'
op|'('
name|'port'
op|')'
newline|'\n'
dedent|''
dedent|''
name|'return'
op|'{'
string|"'ports'"
op|':'
name|'result'
op|'}'
newline|'\n'
nl|'\n'
nl|'\n'
DECL|function|fake_show_port
dedent|''
name|'def'
name|'fake_show_port'
op|'('
name|'self'
op|','
name|'context'
op|','
name|'port_id'
op|','
op|'**'
name|'kwargs'
op|')'
op|':'
newline|'\n'
indent|'    '
name|'for'
name|'port'
name|'in'
name|'ports'
op|':'
newline|'\n'
indent|'        '
name|'if'
name|'port'
op|'['
string|"'id'"
op|']'
op|'=='
name|'port_id'
op|':'
newline|'\n'
indent|'            '
name|'return'
op|'{'
string|"'port'"
op|':'
name|'port'
op|'}'
newline|'\n'
dedent|''
dedent|''
name|'else'
op|':'
newline|'\n'
indent|'        '
name|'raise'
name|'exception'
op|'.'
name|'PortNotFound'
op|'('
name|'port_id'
op|'='
name|'port_id'
op|')'
newline|'\n'
nl|'\n'
nl|'\n'
DECL|function|fake_attach_interface
dedent|''
dedent|''
name|'def'
name|'fake_attach_interface'
op|'('
name|'self'
op|','
name|'context'
op|','
name|'instance'
op|','
name|'network_id'
op|','
name|'port_id'
op|','
nl|'\n'
name|'requested_ip'
op|'='
string|"'192.168.1.3'"
op|')'
op|':'
newline|'\n'
indent|'    '
name|'if'
name|'not'
name|'network_id'
op|':'
newline|'\n'
comment|'# if no network_id is given when add a port to an instance, use the'
nl|'\n'
comment|'# first default network.'
nl|'\n'
indent|'        '
name|'network_id'
op|'='
name|'fake_networks'
op|'['
number|'0'
op|']'
newline|'\n'
dedent|''
name|'if'
name|'network_id'
op|'=='
name|'FAKE_BAD_NET_ID'
op|':'
newline|'\n'
indent|'        '
name|'raise'
name|'exception'
op|'.'
name|'NetworkNotFound'
op|'('
name|'network_id'
op|'='
name|'network_id'
op|')'
newline|'\n'
dedent|''
name|'if'
name|'not'
name|'port_id'
op|':'
newline|'\n'
indent|'        '
name|'port_id'
op|'='
name|'ports'
op|'['
name|'fake_networks'
op|'.'
name|'index'
op|'('
name|'network_id'
op|')'
op|']'
op|'['
string|"'id'"
op|']'
newline|'\n'
dedent|''
name|'if'
name|'port_id'
op|'=='
name|'FAKE_NOT_FOUND_PORT_ID'
op|':'
newline|'\n'
indent|'        '
name|'raise'
name|'exception'
op|'.'
name|'PortNotFound'
op|'('
name|'port_id'
op|'='
name|'port_id'
op|')'
newline|'\n'
dedent|''
name|'vif'
op|'='
name|'fake_network_cache_model'
op|'.'
name|'new_vif'
op|'('
op|')'
newline|'\n'
name|'vif'
op|'['
string|"'id'"
op|']'
op|'='
name|'port_id'
newline|'\n'
name|'vif'
op|'['
string|"'network'"
op|']'
op|'['
string|"'id'"
op|']'
op|'='
name|'network_id'
newline|'\n'
name|'vif'
op|'['
string|"'network'"
op|']'
op|'['
string|"'subnets'"
op|']'
op|'['
number|'0'
op|']'
op|'['
string|"'ips'"
op|']'
op|'['
number|'0'
op|']'
op|'['
string|"'address'"
op|']'
op|'='
name|'requested_ip'
newline|'\n'
name|'return'
name|'vif'
newline|'\n'
nl|'\n'
nl|'\n'
DECL|function|fake_detach_interface
dedent|''
name|'def'
name|'fake_detach_interface'
op|'('
name|'self'
op|','
name|'context'
op|','
name|'instance'
op|','
name|'port_id'
op|')'
op|':'
newline|'\n'
indent|'    '
name|'for'
name|'port'
name|'in'
name|'ports'
op|':'
newline|'\n'
indent|'        '
name|'if'
name|'port'
op|'['
string|"'id'"
op|']'
op|'=='
name|'port_id'
op|':'
newline|'\n'
indent|'            '
name|'return'
newline|'\n'
dedent|''
dedent|''
name|'raise'
name|'exception'
op|'.'
name|'PortNotFound'
op|'('
name|'port_id'
op|'='
name|'port_id'
op|')'
newline|'\n'
nl|'\n'
nl|'\n'
DECL|function|fake_get_instance
dedent|''
name|'def'
name|'fake_get_instance'
op|'('
name|'self'
op|','
op|'*'
name|'args'
op|','
op|'**'
name|'kwargs'
op|')'
op|':'
newline|'\n'
indent|'    '
name|'return'
name|'objects'
op|'.'
name|'Instance'
op|'('
name|'uuid'
op|'='
name|'FAKE_UUID1'
op|')'
newline|'\n'
nl|'\n'
nl|'\n'
DECL|class|InterfaceAttachTestsV21
dedent|''
name|'class'
name|'InterfaceAttachTestsV21'
op|'('
name|'test'
op|'.'
name|'NoDBTestCase'
op|')'
op|':'
newline|'\n'
DECL|variable|controller_cls
indent|'    '
name|'controller_cls'
op|'='
name|'attach_interfaces_v21'
op|'.'
name|'InterfaceAttachmentController'
newline|'\n'
DECL|variable|validate_exc
name|'validate_exc'
op|'='
name|'exception'
op|'.'
name|'ValidationError'
newline|'\n'
DECL|variable|in_use_exc
name|'in_use_exc'
op|'='
name|'exc'
op|'.'
name|'HTTPConflict'
newline|'\n'
DECL|variable|not_found_exc
name|'not_found_exc'
op|'='
name|'exc'
op|'.'
name|'HTTPNotFound'
newline|'\n'
DECL|variable|not_usable_exc
name|'not_usable_exc'
op|'='
name|'exc'
op|'.'
name|'HTTPBadRequest'
newline|'\n'
nl|'\n'
DECL|member|setUp
name|'def'
name|'setUp'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'super'
op|'('
name|'InterfaceAttachTestsV21'
op|','
name|'self'
op|')'
op|'.'
name|'setUp'
op|'('
op|')'
newline|'\n'
name|'self'
op|'.'
name|'flags'
op|'('
name|'timeout'
op|'='
number|'30'
op|','
name|'group'
op|'='
string|"'neutron'"
op|')'
newline|'\n'
name|'self'
op|'.'
name|'stubs'
op|'.'
name|'Set'
op|'('
name|'network_api'
op|'.'
name|'API'
op|','
string|"'show_port'"
op|','
name|'fake_show_port'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'stubs'
op|'.'
name|'Set'
op|'('
name|'network_api'
op|'.'
name|'API'
op|','
string|"'list_ports'"
op|','
name|'fake_list_ports'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'stubs'
op|'.'
name|'Set'
op|'('
name|'compute_api'
op|'.'
name|'API'
op|','
string|"'get'"
op|','
name|'fake_get_instance'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'expected_show'
op|'='
op|'{'
string|"'interfaceAttachment'"
op|':'
nl|'\n'
op|'{'
string|"'net_id'"
op|':'
name|'FAKE_NET_ID1'
op|','
nl|'\n'
string|"'port_id'"
op|':'
name|'FAKE_PORT_ID1'
op|','
nl|'\n'
string|"'mac_addr'"
op|':'
name|'port_data1'
op|'['
string|"'mac_address'"
op|']'
op|','
nl|'\n'
string|"'port_state'"
op|':'
name|'port_data1'
op|'['
string|"'status'"
op|']'
op|','
nl|'\n'
string|"'fixed_ips'"
op|':'
name|'port_data1'
op|'['
string|"'fixed_ips'"
op|']'
op|','
nl|'\n'
op|'}'
op|'}'
newline|'\n'
name|'self'
op|'.'
name|'attachments'
op|'='
name|'self'
op|'.'
name|'controller_cls'
op|'('
op|')'
newline|'\n'
name|'self'
op|'.'
name|'req'
op|'='
name|'fakes'
op|'.'
name|'HTTPRequest'
op|'.'
name|'blank'
op|'('
string|"''"
op|')'
newline|'\n'
nl|'\n'
dedent|''
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'.'
name|'object'
op|'('
name|'compute_api'
op|'.'
name|'API'
op|','
string|"'get'"
op|','
nl|'\n'
name|'side_effect'
op|'='
name|'exception'
op|'.'
name|'InstanceNotFound'
op|'('
name|'instance_id'
op|'='
string|"''"
op|')'
op|')'
newline|'\n'
DECL|member|_test_instance_not_found
name|'def'
name|'_test_instance_not_found'
op|'('
name|'self'
op|','
name|'func'
op|','
name|'args'
op|','
name|'mock_get'
op|','
name|'kwargs'
op|'='
name|'None'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'if'
name|'not'
name|'kwargs'
op|':'
newline|'\n'
indent|'            '
name|'kwargs'
op|'='
op|'{'
op|'}'
newline|'\n'
dedent|''
name|'self'
op|'.'
name|'assertRaises'
op|'('
name|'exc'
op|'.'
name|'HTTPNotFound'
op|','
name|'func'
op|','
name|'self'
op|'.'
name|'req'
op|','
op|'*'
name|'args'
op|','
op|'**'
name|'kwargs'
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_show_instance_not_found
dedent|''
name|'def'
name|'test_show_instance_not_found'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'self'
op|'.'
name|'_test_instance_not_found'
op|'('
name|'self'
op|'.'
name|'attachments'
op|'.'
name|'show'
op|','
op|'('
string|"'fake'"
op|','
string|"'fake'"
op|')'
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_index_instance_not_found
dedent|''
name|'def'
name|'test_index_instance_not_found'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'self'
op|'.'
name|'_test_instance_not_found'
op|'('
name|'self'
op|'.'
name|'attachments'
op|'.'
name|'index'
op|','
op|'('
string|"'fake'"
op|','
op|')'
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_detach_interface_instance_not_found
dedent|''
name|'def'
name|'test_detach_interface_instance_not_found'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'self'
op|'.'
name|'_test_instance_not_found'
op|'('
name|'self'
op|'.'
name|'attachments'
op|'.'
name|'delete'
op|','
nl|'\n'
op|'('
string|"'fake'"
op|','
string|"'fake'"
op|')'
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_attach_interface_instance_not_found
dedent|''
name|'def'
name|'test_attach_interface_instance_not_found'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'self'
op|'.'
name|'_test_instance_not_found'
op|'('
name|'self'
op|'.'
name|'attachments'
op|'.'
name|'create'
op|','
op|'('
string|"'fake'"
op|','
op|')'
op|','
nl|'\n'
name|'kwargs'
op|'='
op|'{'
string|"'body'"
op|':'
op|'{'
string|"'interfaceAttachment'"
op|':'
op|'{'
op|'}'
op|'}'
op|'}'
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_show
dedent|''
name|'def'
name|'test_show'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'result'
op|'='
name|'self'
op|'.'
name|'attachments'
op|'.'
name|'show'
op|'('
name|'self'
op|'.'
name|'req'
op|','
name|'FAKE_UUID1'
op|','
name|'FAKE_PORT_ID1'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
name|'self'
op|'.'
name|'expected_show'
op|','
name|'result'
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_show_with_port_not_found
dedent|''
name|'def'
name|'test_show_with_port_not_found'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'self'
op|'.'
name|'assertRaises'
op|'('
name|'exc'
op|'.'
name|'HTTPNotFound'
op|','
nl|'\n'
name|'self'
op|'.'
name|'attachments'
op|'.'
name|'show'
op|','
name|'self'
op|'.'
name|'req'
op|','
name|'FAKE_UUID2'
op|','
nl|'\n'
name|'FAKE_PORT_ID1'
op|')'
newline|'\n'
nl|'\n'
dedent|''
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'.'
name|'object'
op|'('
name|'network_api'
op|'.'
name|'API'
op|','
string|"'show_port'"
op|','
nl|'\n'
name|'side_effect'
op|'='
name|'exception'
op|'.'
name|'Forbidden'
op|')'
newline|'\n'
DECL|member|test_show_forbidden
name|'def'
name|'test_show_forbidden'
op|'('
name|'self'
op|','
name|'show_port_mock'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'self'
op|'.'
name|'assertRaises'
op|'('
name|'exc'
op|'.'
name|'HTTPForbidden'
op|','
nl|'\n'
name|'self'
op|'.'
name|'attachments'
op|'.'
name|'show'
op|','
name|'self'
op|'.'
name|'req'
op|','
name|'FAKE_UUID1'
op|','
nl|'\n'
name|'FAKE_PORT_ID1'
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_delete
dedent|''
name|'def'
name|'test_delete'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'self'
op|'.'
name|'stubs'
op|'.'
name|'Set'
op|'('
name|'compute_api'
op|'.'
name|'API'
op|','
string|"'detach_interface'"
op|','
nl|'\n'
name|'fake_detach_interface'
op|')'
newline|'\n'
nl|'\n'
name|'result'
op|'='
name|'self'
op|'.'
name|'attachments'
op|'.'
name|'delete'
op|'('
name|'self'
op|'.'
name|'req'
op|','
name|'FAKE_UUID1'
op|','
name|'FAKE_PORT_ID1'
op|')'
newline|'\n'
comment|'# NOTE: on v2.1, http status code is set as wsgi_code of API'
nl|'\n'
comment|'# method instead of status_int in a response object.'
nl|'\n'
name|'if'
name|'isinstance'
op|'('
name|'self'
op|'.'
name|'attachments'
op|','
nl|'\n'
name|'attach_interfaces_v21'
op|'.'
name|'InterfaceAttachmentController'
op|')'
op|':'
newline|'\n'
indent|'            '
name|'status_int'
op|'='
name|'self'
op|'.'
name|'attachments'
op|'.'
name|'delete'
op|'.'
name|'wsgi_code'
newline|'\n'
dedent|''
name|'else'
op|':'
newline|'\n'
indent|'            '
name|'status_int'
op|'='
name|'result'
op|'.'
name|'status_int'
newline|'\n'
dedent|''
name|'self'
op|'.'
name|'assertEqual'
op|'('
number|'202'
op|','
name|'status_int'
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_detach_interface_instance_locked
dedent|''
name|'def'
name|'test_detach_interface_instance_locked'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
DECL|function|fake_detach_interface_from_locked_server
indent|'        '
name|'def'
name|'fake_detach_interface_from_locked_server'
op|'('
name|'self'
op|','
name|'context'
op|','
nl|'\n'
name|'instance'
op|','
name|'port_id'
op|')'
op|':'
newline|'\n'
indent|'            '
name|'raise'
name|'exception'
op|'.'
name|'InstanceIsLocked'
op|'('
name|'instance_uuid'
op|'='
name|'FAKE_UUID1'
op|')'
newline|'\n'
nl|'\n'
dedent|''
name|'self'
op|'.'
name|'stubs'
op|'.'
name|'Set'
op|'('
name|'compute_api'
op|'.'
name|'API'
op|','
nl|'\n'
string|"'detach_interface'"
op|','
nl|'\n'
name|'fake_detach_interface_from_locked_server'
op|')'
newline|'\n'
nl|'\n'
name|'self'
op|'.'
name|'assertRaises'
op|'('
name|'exc'
op|'.'
name|'HTTPConflict'
op|','
nl|'\n'
name|'self'
op|'.'
name|'attachments'
op|'.'
name|'delete'
op|','
nl|'\n'
name|'self'
op|'.'
name|'req'
op|','
nl|'\n'
name|'FAKE_UUID1'
op|','
nl|'\n'
name|'FAKE_PORT_ID1'
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_delete_interface_not_found
dedent|''
name|'def'
name|'test_delete_interface_not_found'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'self'
op|'.'
name|'stubs'
op|'.'
name|'Set'
op|'('
name|'compute_api'
op|'.'
name|'API'
op|','
string|"'detach_interface'"
op|','
nl|'\n'
name|'fake_detach_interface'
op|')'
newline|'\n'
nl|'\n'
name|'self'
op|'.'
name|'assertRaises'
op|'('
name|'exc'
op|'.'
name|'HTTPNotFound'
op|','
nl|'\n'
name|'self'
op|'.'
name|'attachments'
op|'.'
name|'delete'
op|','
nl|'\n'
name|'self'
op|'.'
name|'req'
op|','
nl|'\n'
name|'FAKE_UUID1'
op|','
nl|'\n'
string|"'invaid-port-id'"
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_attach_interface_instance_locked
dedent|''
name|'def'
name|'test_attach_interface_instance_locked'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
DECL|function|fake_attach_interface_to_locked_server
indent|'        '
name|'def'
name|'fake_attach_interface_to_locked_server'
op|'('
name|'self'
op|','
name|'context'
op|','
nl|'\n'
name|'instance'
op|','
name|'network_id'
op|','
name|'port_id'
op|','
name|'requested_ip'
op|')'
op|':'
newline|'\n'
indent|'            '
name|'raise'
name|'exception'
op|'.'
name|'InstanceIsLocked'
op|'('
name|'instance_uuid'
op|'='
name|'FAKE_UUID1'
op|')'
newline|'\n'
nl|'\n'
dedent|''
name|'self'
op|'.'
name|'stubs'
op|'.'
name|'Set'
op|'('
name|'compute_api'
op|'.'
name|'API'
op|','
nl|'\n'
string|"'attach_interface'"
op|','
nl|'\n'
name|'fake_attach_interface_to_locked_server'
op|')'
newline|'\n'
name|'body'
op|'='
op|'{'
op|'}'
newline|'\n'
name|'self'
op|'.'
name|'assertRaises'
op|'('
name|'exc'
op|'.'
name|'HTTPConflict'
op|','
nl|'\n'
name|'self'
op|'.'
name|'attachments'
op|'.'
name|'create'
op|','
name|'self'
op|'.'
name|'req'
op|','
name|'FAKE_UUID1'
op|','
nl|'\n'
name|'body'
op|'='
name|'body'
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_attach_interface_without_network_id
dedent|''
name|'def'
name|'test_attach_interface_without_network_id'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'self'
op|'.'
name|'stubs'
op|'.'
name|'Set'
op|'('
name|'compute_api'
op|'.'
name|'API'
op|','
string|"'attach_interface'"
op|','
nl|'\n'
name|'fake_attach_interface'
op|')'
newline|'\n'
name|'body'
op|'='
op|'{'
op|'}'
newline|'\n'
name|'result'
op|'='
name|'self'
op|'.'
name|'attachments'
op|'.'
name|'create'
op|'('
name|'self'
op|'.'
name|'req'
op|','
name|'FAKE_UUID1'
op|','
name|'body'
op|'='
name|'body'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
name|'result'
op|'['
string|"'interfaceAttachment'"
op|']'
op|'['
string|"'net_id'"
op|']'
op|','
nl|'\n'
name|'FAKE_NET_ID1'
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_attach_interface_with_network_id
dedent|''
name|'def'
name|'test_attach_interface_with_network_id'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'self'
op|'.'
name|'stubs'
op|'.'
name|'Set'
op|'('
name|'compute_api'
op|'.'
name|'API'
op|','
string|"'attach_interface'"
op|','
nl|'\n'
name|'fake_attach_interface'
op|')'
newline|'\n'
name|'body'
op|'='
op|'{'
string|"'interfaceAttachment'"
op|':'
op|'{'
string|"'net_id'"
op|':'
name|'FAKE_NET_ID2'
op|'}'
op|'}'
newline|'\n'
name|'result'
op|'='
name|'self'
op|'.'
name|'attachments'
op|'.'
name|'create'
op|'('
name|'self'
op|'.'
name|'req'
op|','
name|'FAKE_UUID1'
op|','
name|'body'
op|'='
name|'body'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
name|'result'
op|'['
string|"'interfaceAttachment'"
op|']'
op|'['
string|"'net_id'"
op|']'
op|','
nl|'\n'
name|'FAKE_NET_ID2'
op|')'
newline|'\n'
nl|'\n'
DECL|member|_attach_interface_bad_request_case
dedent|''
name|'def'
name|'_attach_interface_bad_request_case'
op|'('
name|'self'
op|','
name|'body'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'self'
op|'.'
name|'stubs'
op|'.'
name|'Set'
op|'('
name|'compute_api'
op|'.'
name|'API'
op|','
string|"'attach_interface'"
op|','
nl|'\n'
name|'fake_attach_interface'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertRaises'
op|'('
name|'exc'
op|'.'
name|'HTTPBadRequest'
op|','
nl|'\n'
name|'self'
op|'.'
name|'attachments'
op|'.'
name|'create'
op|','
name|'self'
op|'.'
name|'req'
op|','
name|'FAKE_UUID1'
op|','
nl|'\n'
name|'body'
op|'='
name|'body'
op|')'
newline|'\n'
nl|'\n'
DECL|member|_attach_interface_not_found_case
dedent|''
name|'def'
name|'_attach_interface_not_found_case'
op|'('
name|'self'
op|','
name|'body'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'self'
op|'.'
name|'stubs'
op|'.'
name|'Set'
op|'('
name|'compute_api'
op|'.'
name|'API'
op|','
string|"'attach_interface'"
op|','
nl|'\n'
name|'fake_attach_interface'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertRaises'
op|'('
name|'self'
op|'.'
name|'not_found_exc'
op|','
nl|'\n'
name|'self'
op|'.'
name|'attachments'
op|'.'
name|'create'
op|','
name|'self'
op|'.'
name|'req'
op|','
name|'FAKE_UUID1'
op|','
nl|'\n'
name|'body'
op|'='
name|'body'
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_attach_interface_with_port_and_network_id
dedent|''
name|'def'
name|'test_attach_interface_with_port_and_network_id'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'body'
op|'='
op|'{'
nl|'\n'
string|"'interfaceAttachment'"
op|':'
op|'{'
nl|'\n'
string|"'port_id'"
op|':'
name|'FAKE_PORT_ID1'
op|','
nl|'\n'
string|"'net_id'"
op|':'
name|'FAKE_NET_ID2'
nl|'\n'
op|'}'
nl|'\n'
op|'}'
newline|'\n'
name|'self'
op|'.'
name|'_attach_interface_bad_request_case'
op|'('
name|'body'
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_attach_interface_with_not_found_network_id
dedent|''
name|'def'
name|'test_attach_interface_with_not_found_network_id'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'body'
op|'='
op|'{'
nl|'\n'
string|"'interfaceAttachment'"
op|':'
op|'{'
nl|'\n'
string|"'net_id'"
op|':'
name|'FAKE_BAD_NET_ID'
nl|'\n'
op|'}'
nl|'\n'
op|'}'
newline|'\n'
name|'self'
op|'.'
name|'_attach_interface_not_found_case'
op|'('
name|'body'
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_attach_interface_with_not_found_port_id
dedent|''
name|'def'
name|'test_attach_interface_with_not_found_port_id'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'body'
op|'='
op|'{'
nl|'\n'
string|"'interfaceAttachment'"
op|':'
op|'{'
nl|'\n'
string|"'port_id'"
op|':'
name|'FAKE_NOT_FOUND_PORT_ID'
nl|'\n'
op|'}'
nl|'\n'
op|'}'
newline|'\n'
name|'self'
op|'.'
name|'_attach_interface_not_found_case'
op|'('
name|'body'
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_attach_interface_with_invalid_state
dedent|''
name|'def'
name|'test_attach_interface_with_invalid_state'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
DECL|function|fake_attach_interface_invalid_state
indent|'        '
name|'def'
name|'fake_attach_interface_invalid_state'
op|'('
op|'*'
name|'args'
op|','
op|'**'
name|'kwargs'
op|')'
op|':'
newline|'\n'
indent|'            '
name|'raise'
name|'exception'
op|'.'
name|'InstanceInvalidState'
op|'('
nl|'\n'
name|'instance_uuid'
op|'='
string|"''"
op|','
name|'attr'
op|'='
string|"''"
op|','
name|'state'
op|'='
string|"''"
op|','
nl|'\n'
name|'method'
op|'='
string|"'attach_interface'"
op|')'
newline|'\n'
nl|'\n'
dedent|''
name|'self'
op|'.'
name|'stubs'
op|'.'
name|'Set'
op|'('
name|'compute_api'
op|'.'
name|'API'
op|','
string|"'attach_interface'"
op|','
nl|'\n'
name|'fake_attach_interface_invalid_state'
op|')'
newline|'\n'
name|'body'
op|'='
op|'{'
string|"'interfaceAttachment'"
op|':'
op|'{'
string|"'net_id'"
op|':'
name|'FAKE_NET_ID1'
op|'}'
op|'}'
newline|'\n'
name|'self'
op|'.'
name|'assertRaises'
op|'('
name|'exc'
op|'.'
name|'HTTPConflict'
op|','
nl|'\n'
name|'self'
op|'.'
name|'attachments'
op|'.'
name|'create'
op|','
name|'self'
op|'.'
name|'req'
op|','
name|'FAKE_UUID1'
op|','
nl|'\n'
name|'body'
op|'='
name|'body'
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_detach_interface_with_invalid_state
dedent|''
name|'def'
name|'test_detach_interface_with_invalid_state'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
DECL|function|fake_detach_interface_invalid_state
indent|'        '
name|'def'
name|'fake_detach_interface_invalid_state'
op|'('
op|'*'
name|'args'
op|','
op|'**'
name|'kwargs'
op|')'
op|':'
newline|'\n'
indent|'            '
name|'raise'
name|'exception'
op|'.'
name|'InstanceInvalidState'
op|'('
nl|'\n'
name|'instance_uuid'
op|'='
string|"''"
op|','
name|'attr'
op|'='
string|"''"
op|','
name|'state'
op|'='
string|"''"
op|','
nl|'\n'
name|'method'
op|'='
string|"'detach_interface'"
op|')'
newline|'\n'
nl|'\n'
dedent|''
name|'self'
op|'.'
name|'stubs'
op|'.'
name|'Set'
op|'('
name|'compute_api'
op|'.'
name|'API'
op|','
string|"'detach_interface'"
op|','
nl|'\n'
name|'fake_detach_interface_invalid_state'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertRaises'
op|'('
name|'exc'
op|'.'
name|'HTTPConflict'
op|','
nl|'\n'
name|'self'
op|'.'
name|'attachments'
op|'.'
name|'delete'
op|','
nl|'\n'
name|'self'
op|'.'
name|'req'
op|','
nl|'\n'
name|'FAKE_UUID1'
op|','
nl|'\n'
name|'FAKE_NET_ID1'
op|')'
newline|'\n'
nl|'\n'
dedent|''
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'.'
name|'object'
op|'('
name|'compute_api'
op|'.'
name|'API'
op|','
string|"'detach_interface'"
op|','
nl|'\n'
name|'side_effect'
op|'='
name|'NotImplementedError'
op|'('
op|')'
op|')'
newline|'\n'
DECL|member|test_detach_interface_with_not_implemented
name|'def'
name|'test_detach_interface_with_not_implemented'
op|'('
name|'self'
op|','
name|'_mock'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'self'
op|'.'
name|'assertRaises'
op|'('
name|'exc'
op|'.'
name|'HTTPNotImplemented'
op|','
nl|'\n'
name|'self'
op|'.'
name|'attachments'
op|'.'
name|'delete'
op|','
nl|'\n'
name|'self'
op|'.'
name|'req'
op|','
name|'FAKE_UUID1'
op|','
name|'FAKE_NET_ID1'
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_attach_interface_invalid_fixed_ip
dedent|''
name|'def'
name|'test_attach_interface_invalid_fixed_ip'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'body'
op|'='
op|'{'
nl|'\n'
string|"'interfaceAttachment'"
op|':'
op|'{'
nl|'\n'
string|"'net_id'"
op|':'
name|'FAKE_NET_ID1'
op|','
nl|'\n'
string|"'fixed_ips'"
op|':'
op|'['
op|'{'
string|"'ip_address'"
op|':'
string|"'invalid_ip'"
op|'}'
op|']'
nl|'\n'
op|'}'
nl|'\n'
op|'}'
newline|'\n'
name|'self'
op|'.'
name|'assertRaises'
op|'('
name|'self'
op|'.'
name|'validate_exc'
op|','
nl|'\n'
name|'self'
op|'.'
name|'attachments'
op|'.'
name|'create'
op|','
name|'self'
op|'.'
name|'req'
op|','
name|'FAKE_UUID1'
op|','
nl|'\n'
name|'body'
op|'='
name|'body'
op|')'
newline|'\n'
nl|'\n'
dedent|''
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'.'
name|'object'
op|'('
name|'compute_api'
op|'.'
name|'API'
op|','
string|"'get'"
op|')'
newline|'\n'
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'.'
name|'object'
op|'('
name|'compute_api'
op|'.'
name|'API'
op|','
string|"'attach_interface'"
op|')'
newline|'\n'
DECL|member|test_attach_interface_fixed_ip_already_in_use
name|'def'
name|'test_attach_interface_fixed_ip_already_in_use'
op|'('
name|'self'
op|','
nl|'\n'
name|'attach_mock'
op|','
nl|'\n'
name|'get_mock'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'fake_instance'
op|'='
name|'objects'
op|'.'
name|'Instance'
op|'('
name|'uuid'
op|'='
name|'FAKE_UUID1'
op|')'
newline|'\n'
name|'get_mock'
op|'.'
name|'return_value'
op|'='
name|'fake_instance'
newline|'\n'
name|'attach_mock'
op|'.'
name|'side_effect'
op|'='
name|'exception'
op|'.'
name|'FixedIpAlreadyInUse'
op|'('
nl|'\n'
name|'address'
op|'='
string|"'10.0.2.2'"
op|','
name|'instance_uuid'
op|'='
name|'FAKE_UUID1'
op|')'
newline|'\n'
name|'body'
op|'='
op|'{'
op|'}'
newline|'\n'
name|'self'
op|'.'
name|'assertRaises'
op|'('
name|'self'
op|'.'
name|'in_use_exc'
op|','
nl|'\n'
name|'self'
op|'.'
name|'attachments'
op|'.'
name|'create'
op|','
name|'self'
op|'.'
name|'req'
op|','
name|'FAKE_UUID1'
op|','
nl|'\n'
name|'body'
op|'='
name|'body'
op|')'
newline|'\n'
name|'ctxt'
op|'='
name|'self'
op|'.'
name|'req'
op|'.'
name|'environ'
op|'['
string|"'nova.context'"
op|']'
newline|'\n'
name|'attach_mock'
op|'.'
name|'assert_called_once_with'
op|'('
name|'ctxt'
op|','
name|'fake_instance'
op|','
name|'None'
op|','
nl|'\n'
name|'None'
op|','
name|'None'
op|')'
newline|'\n'
name|'get_mock'
op|'.'
name|'assert_called_once_with'
op|'('
name|'ctxt'
op|','
name|'FAKE_UUID1'
op|','
nl|'\n'
name|'want_objects'
op|'='
name|'True'
op|','
nl|'\n'
name|'expected_attrs'
op|'='
name|'None'
op|')'
newline|'\n'
nl|'\n'
dedent|''
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'.'
name|'object'
op|'('
name|'compute_api'
op|'.'
name|'API'
op|','
string|"'get'"
op|')'
newline|'\n'
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'.'
name|'object'
op|'('
name|'compute_api'
op|'.'
name|'API'
op|','
string|"'attach_interface'"
op|')'
newline|'\n'
DECL|member|test_attach_interface_port_in_use
name|'def'
name|'test_attach_interface_port_in_use'
op|'('
name|'self'
op|','
nl|'\n'
name|'attach_mock'
op|','
nl|'\n'
name|'get_mock'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'fake_instance'
op|'='
name|'objects'
op|'.'
name|'Instance'
op|'('
name|'uuid'
op|'='
name|'FAKE_UUID1'
op|')'
newline|'\n'
name|'get_mock'
op|'.'
name|'return_value'
op|'='
name|'fake_instance'
newline|'\n'
name|'attach_mock'
op|'.'
name|'side_effect'
op|'='
name|'exception'
op|'.'
name|'PortInUse'
op|'('
nl|'\n'
name|'port_id'
op|'='
name|'FAKE_PORT_ID1'
op|')'
newline|'\n'
name|'body'
op|'='
op|'{'
op|'}'
newline|'\n'
name|'self'
op|'.'
name|'assertRaises'
op|'('
name|'self'
op|'.'
name|'in_use_exc'
op|','
nl|'\n'
name|'self'
op|'.'
name|'attachments'
op|'.'
name|'create'
op|','
name|'self'
op|'.'
name|'req'
op|','
name|'FAKE_UUID1'
op|','
nl|'\n'
name|'body'
op|'='
name|'body'
op|')'
newline|'\n'
name|'ctxt'
op|'='
name|'self'
op|'.'
name|'req'
op|'.'
name|'environ'
op|'['
string|"'nova.context'"
op|']'
newline|'\n'
name|'attach_mock'
op|'.'
name|'assert_called_once_with'
op|'('
name|'ctxt'
op|','
name|'fake_instance'
op|','
name|'None'
op|','
nl|'\n'
name|'None'
op|','
name|'None'
op|')'
newline|'\n'
name|'get_mock'
op|'.'
name|'assert_called_once_with'
op|'('
name|'ctxt'
op|','
name|'FAKE_UUID1'
op|','
nl|'\n'
name|'want_objects'
op|'='
name|'True'
op|','
nl|'\n'
name|'expected_attrs'
op|'='
name|'None'
op|')'
newline|'\n'
nl|'\n'
dedent|''
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'.'
name|'object'
op|'('
name|'compute_api'
op|'.'
name|'API'
op|','
string|"'get'"
op|')'
newline|'\n'
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'.'
name|'object'
op|'('
name|'compute_api'
op|'.'
name|'API'
op|','
string|"'attach_interface'"
op|')'
newline|'\n'
DECL|member|test_attach_interface_port_not_usable
name|'def'
name|'test_attach_interface_port_not_usable'
op|'('
name|'self'
op|','
nl|'\n'
name|'attach_mock'
op|','
nl|'\n'
name|'get_mock'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'fake_instance'
op|'='
name|'objects'
op|'.'
name|'Instance'
op|'('
name|'uuid'
op|'='
name|'FAKE_UUID1'
op|')'
newline|'\n'
name|'get_mock'
op|'.'
name|'return_value'
op|'='
name|'fake_instance'
newline|'\n'
name|'attach_mock'
op|'.'
name|'side_effect'
op|'='
name|'exception'
op|'.'
name|'PortNotUsable'
op|'('
nl|'\n'
name|'port_id'
op|'='
name|'FAKE_PORT_ID1'
op|','
nl|'\n'
name|'instance'
op|'='
name|'fake_instance'
op|'.'
name|'uuid'
op|')'
newline|'\n'
name|'body'
op|'='
op|'{'
op|'}'
newline|'\n'
name|'self'
op|'.'
name|'assertRaises'
op|'('
name|'self'
op|'.'
name|'not_usable_exc'
op|','
nl|'\n'
name|'self'
op|'.'
name|'attachments'
op|'.'
name|'create'
op|','
name|'self'
op|'.'
name|'req'
op|','
name|'FAKE_UUID1'
op|','
nl|'\n'
name|'body'
op|'='
name|'body'
op|')'
newline|'\n'
name|'ctxt'
op|'='
name|'self'
op|'.'
name|'req'
op|'.'
name|'environ'
op|'['
string|"'nova.context'"
op|']'
newline|'\n'
name|'attach_mock'
op|'.'
name|'assert_called_once_with'
op|'('
name|'ctxt'
op|','
name|'fake_instance'
op|','
name|'None'
op|','
nl|'\n'
name|'None'
op|','
name|'None'
op|')'
newline|'\n'
name|'get_mock'
op|'.'
name|'assert_called_once_with'
op|'('
name|'ctxt'
op|','
name|'FAKE_UUID1'
op|','
nl|'\n'
name|'want_objects'
op|'='
name|'True'
op|','
nl|'\n'
name|'expected_attrs'
op|'='
name|'None'
op|')'
newline|'\n'
nl|'\n'
dedent|''
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'.'
name|'object'
op|'('
name|'compute_api'
op|'.'
name|'API'
op|','
string|"'get'"
op|')'
newline|'\n'
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'.'
name|'object'
op|'('
name|'compute_api'
op|'.'
name|'API'
op|','
string|"'attach_interface'"
op|')'
newline|'\n'
DECL|member|test_attach_interface_failed_no_network
name|'def'
name|'test_attach_interface_failed_no_network'
op|'('
name|'self'
op|','
name|'attach_mock'
op|','
name|'get_mock'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'fake_instance'
op|'='
name|'objects'
op|'.'
name|'Instance'
op|'('
name|'uuid'
op|'='
name|'FAKE_UUID1'
op|','
nl|'\n'
name|'project_id'
op|'='
name|'FAKE_UUID2'
op|')'
newline|'\n'
name|'get_mock'
op|'.'
name|'return_value'
op|'='
name|'fake_instance'
newline|'\n'
name|'attach_mock'
op|'.'
name|'side_effect'
op|'='
op|'('
nl|'\n'
name|'exception'
op|'.'
name|'InterfaceAttachFailedNoNetwork'
op|'('
name|'project_id'
op|'='
name|'FAKE_UUID2'
op|')'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertRaises'
op|'('
name|'exc'
op|'.'
name|'HTTPBadRequest'
op|','
name|'self'
op|'.'
name|'attachments'
op|'.'
name|'create'
op|','
nl|'\n'
name|'self'
op|'.'
name|'req'
op|','
name|'FAKE_UUID1'
op|','
name|'body'
op|'='
op|'{'
op|'}'
op|')'
newline|'\n'
name|'ctxt'
op|'='
name|'self'
op|'.'
name|'req'
op|'.'
name|'environ'
op|'['
string|"'nova.context'"
op|']'
newline|'\n'
name|'attach_mock'
op|'.'
name|'assert_called_once_with'
op|'('
name|'ctxt'
op|','
name|'fake_instance'
op|','
name|'None'
op|','
nl|'\n'
name|'None'
op|','
name|'None'
op|')'
newline|'\n'
name|'get_mock'
op|'.'
name|'assert_called_once_with'
op|'('
name|'ctxt'
op|','
name|'FAKE_UUID1'
op|','
nl|'\n'
name|'want_objects'
op|'='
name|'True'
op|','
nl|'\n'
name|'expected_attrs'
op|'='
name|'None'
op|')'
newline|'\n'
nl|'\n'
dedent|''
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'.'
name|'object'
op|'('
name|'compute_api'
op|'.'
name|'API'
op|','
string|"'get'"
op|')'
newline|'\n'
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'.'
name|'object'
op|'('
name|'compute_api'
op|'.'
name|'API'
op|','
string|"'attach_interface'"
op|')'
newline|'\n'
DECL|member|test_attach_interface_no_more_fixed_ips
name|'def'
name|'test_attach_interface_no_more_fixed_ips'
op|'('
name|'self'
op|','
nl|'\n'
name|'attach_mock'
op|','
nl|'\n'
name|'get_mock'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'fake_instance'
op|'='
name|'objects'
op|'.'
name|'Instance'
op|'('
name|'uuid'
op|'='
name|'FAKE_UUID1'
op|')'
newline|'\n'
name|'get_mock'
op|'.'
name|'return_value'
op|'='
name|'fake_instance'
newline|'\n'
name|'attach_mock'
op|'.'
name|'side_effect'
op|'='
name|'exception'
op|'.'
name|'NoMoreFixedIps'
op|'('
nl|'\n'
name|'net'
op|'='
name|'FAKE_NET_ID1'
op|')'
newline|'\n'
name|'body'
op|'='
op|'{'
op|'}'
newline|'\n'
name|'self'
op|'.'
name|'assertRaises'
op|'('
name|'exc'
op|'.'
name|'HTTPBadRequest'
op|','
nl|'\n'
name|'self'
op|'.'
name|'attachments'
op|'.'
name|'create'
op|','
name|'self'
op|'.'
name|'req'
op|','
name|'FAKE_UUID1'
op|','
nl|'\n'
name|'body'
op|'='
name|'body'
op|')'
newline|'\n'
name|'ctxt'
op|'='
name|'self'
op|'.'
name|'req'
op|'.'
name|'environ'
op|'['
string|"'nova.context'"
op|']'
newline|'\n'
name|'attach_mock'
op|'.'
name|'assert_called_once_with'
op|'('
name|'ctxt'
op|','
name|'fake_instance'
op|','
name|'None'
op|','
nl|'\n'
name|'None'
op|','
name|'None'
op|')'
newline|'\n'
name|'get_mock'
op|'.'
name|'assert_called_once_with'
op|'('
name|'ctxt'
op|','
name|'FAKE_UUID1'
op|','
nl|'\n'
name|'want_objects'
op|'='
name|'True'
op|','
nl|'\n'
name|'expected_attrs'
op|'='
name|'None'
op|')'
newline|'\n'
nl|'\n'
DECL|member|_test_attach_interface_with_invalid_parameter
dedent|''
name|'def'
name|'_test_attach_interface_with_invalid_parameter'
op|'('
name|'self'
op|','
name|'param'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'self'
op|'.'
name|'stubs'
op|'.'
name|'Set'
op|'('
name|'compute_api'
op|'.'
name|'API'
op|','
string|"'attach_interface'"
op|','
nl|'\n'
name|'fake_attach_interface'
op|')'
newline|'\n'
name|'body'
op|'='
op|'{'
string|"'interface_attachment'"
op|':'
name|'param'
op|'}'
newline|'\n'
name|'self'
op|'.'
name|'assertRaises'
op|'('
name|'exception'
op|'.'
name|'ValidationError'
op|','
nl|'\n'
name|'self'
op|'.'
name|'attachments'
op|'.'
name|'create'
op|','
name|'self'
op|'.'
name|'req'
op|','
name|'FAKE_UUID1'
op|','
nl|'\n'
name|'body'
op|'='
name|'body'
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_attach_interface_instance_with_non_uuid_net_id
dedent|''
name|'def'
name|'test_attach_interface_instance_with_non_uuid_net_id'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'param'
op|'='
op|'{'
string|"'net_id'"
op|':'
string|"'non_uuid'"
op|'}'
newline|'\n'
name|'self'
op|'.'
name|'_test_attach_interface_with_invalid_parameter'
op|'('
name|'param'
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_attach_interface_instance_with_non_uuid_port_id
dedent|''
name|'def'
name|'test_attach_interface_instance_with_non_uuid_port_id'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'param'
op|'='
op|'{'
string|"'port_id'"
op|':'
string|"'non_uuid'"
op|'}'
newline|'\n'
name|'self'
op|'.'
name|'_test_attach_interface_with_invalid_parameter'
op|'('
name|'param'
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_attach_interface_instance_with_non_array_fixed_ips
dedent|''
name|'def'
name|'test_attach_interface_instance_with_non_array_fixed_ips'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'param'
op|'='
op|'{'
string|"'fixed_ips'"
op|':'
string|"'non_array'"
op|'}'
newline|'\n'
name|'self'
op|'.'
name|'_test_attach_interface_with_invalid_parameter'
op|'('
name|'param'
op|')'
newline|'\n'
nl|'\n'
nl|'\n'
DECL|class|AttachInterfacesPolicyEnforcementv21
dedent|''
dedent|''
name|'class'
name|'AttachInterfacesPolicyEnforcementv21'
op|'('
name|'test'
op|'.'
name|'NoDBTestCase'
op|')'
op|':'
newline|'\n'
nl|'\n'
DECL|member|setUp
indent|'    '
name|'def'
name|'setUp'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'super'
op|'('
name|'AttachInterfacesPolicyEnforcementv21'
op|','
name|'self'
op|')'
op|'.'
name|'setUp'
op|'('
op|')'
newline|'\n'
name|'self'
op|'.'
name|'controller'
op|'='
name|'attach_interfaces_v21'
op|'.'
name|'InterfaceAttachmentController'
op|'('
op|')'
newline|'\n'
name|'self'
op|'.'
name|'req'
op|'='
name|'fakes'
op|'.'
name|'HTTPRequest'
op|'.'
name|'blank'
op|'('
string|"''"
op|')'
newline|'\n'
name|'self'
op|'.'
name|'rule_name'
op|'='
string|'"os_compute_api:os-attach-interfaces"'
newline|'\n'
name|'self'
op|'.'
name|'policy'
op|'.'
name|'set_rules'
op|'('
op|'{'
name|'self'
op|'.'
name|'rule_name'
op|':'
string|'"project:non_fake"'
op|'}'
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_index_attach_interfaces_policy_failed
dedent|''
name|'def'
name|'test_index_attach_interfaces_policy_failed'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'exc'
op|'='
name|'self'
op|'.'
name|'assertRaises'
op|'('
nl|'\n'
name|'exception'
op|'.'
name|'PolicyNotAuthorized'
op|','
nl|'\n'
name|'self'
op|'.'
name|'controller'
op|'.'
name|'index'
op|','
name|'self'
op|'.'
name|'req'
op|','
name|'fakes'
op|'.'
name|'FAKE_UUID'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
nl|'\n'
string|'"Policy doesn\'t allow %s to be performed."'
op|'%'
name|'self'
op|'.'
name|'rule_name'
op|','
nl|'\n'
name|'exc'
op|'.'
name|'format_message'
op|'('
op|')'
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_show_attach_interfaces_policy_failed
dedent|''
name|'def'
name|'test_show_attach_interfaces_policy_failed'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'exc'
op|'='
name|'self'
op|'.'
name|'assertRaises'
op|'('
nl|'\n'
name|'exception'
op|'.'
name|'PolicyNotAuthorized'
op|','
nl|'\n'
name|'self'
op|'.'
name|'controller'
op|'.'
name|'show'
op|','
name|'self'
op|'.'
name|'req'
op|','
name|'fakes'
op|'.'
name|'FAKE_UUID'
op|','
name|'FAKE_PORT_ID1'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
nl|'\n'
string|'"Policy doesn\'t allow %s to be performed."'
op|'%'
name|'self'
op|'.'
name|'rule_name'
op|','
nl|'\n'
name|'exc'
op|'.'
name|'format_message'
op|'('
op|')'
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_create_attach_interfaces_policy_failed
dedent|''
name|'def'
name|'test_create_attach_interfaces_policy_failed'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'exc'
op|'='
name|'self'
op|'.'
name|'assertRaises'
op|'('
nl|'\n'
name|'exception'
op|'.'
name|'PolicyNotAuthorized'
op|','
nl|'\n'
name|'self'
op|'.'
name|'controller'
op|'.'
name|'create'
op|','
name|'self'
op|'.'
name|'req'
op|','
name|'fakes'
op|'.'
name|'FAKE_UUID'
op|','
name|'body'
op|'='
op|'{'
op|'}'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
nl|'\n'
string|'"Policy doesn\'t allow %s to be performed."'
op|'%'
name|'self'
op|'.'
name|'rule_name'
op|','
nl|'\n'
name|'exc'
op|'.'
name|'format_message'
op|'('
op|')'
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_delete_attach_interfaces_policy_failed
dedent|''
name|'def'
name|'test_delete_attach_interfaces_policy_failed'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'exc'
op|'='
name|'self'
op|'.'
name|'assertRaises'
op|'('
nl|'\n'
name|'exception'
op|'.'
name|'PolicyNotAuthorized'
op|','
nl|'\n'
name|'self'
op|'.'
name|'controller'
op|'.'
name|'delete'
op|','
name|'self'
op|'.'
name|'req'
op|','
name|'fakes'
op|'.'
name|'FAKE_UUID'
op|','
name|'FAKE_PORT_ID1'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
nl|'\n'
string|'"Policy doesn\'t allow %s to be performed."'
op|'%'
name|'self'
op|'.'
name|'rule_name'
op|','
nl|'\n'
name|'exc'
op|'.'
name|'format_message'
op|'('
op|')'
op|')'
newline|'\n'
dedent|''
dedent|''
endmarker|''
end_unit
