<filename>nova/tests/unit/scheduler/filters/test_utils.py
begin_unit
comment|'# Copyright 2015 IBM Corp.'
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|'from'
name|'nova'
name|'import'
name|'objects'
newline|'\n'
name|'from'
name|'nova'
op|'.'
name|'scheduler'
op|'.'
name|'filters'
name|'import'
name|'utils'
newline|'\n'
name|'from'
name|'nova'
name|'import'
name|'test'
newline|'\n'
name|'from'
name|'nova'
op|'.'
name|'tests'
op|'.'
name|'unit'
op|'.'
name|'scheduler'
name|'import'
name|'fakes'
newline|'\n'
nl|'\n'
DECL|variable|_AGGREGATE_FIXTURES
name|'_AGGREGATE_FIXTURES'
op|'='
op|'['
nl|'\n'
name|'objects'
op|'.'
name|'Aggregate'
op|'('
nl|'\n'
DECL|variable|id
name|'id'
op|'='
number|'1'
op|','
nl|'\n'
DECL|variable|name
name|'name'
op|'='
string|"'foo'"
op|','
nl|'\n'
DECL|variable|hosts
name|'hosts'
op|'='
op|'['
string|"'fake-host'"
op|']'
op|','
nl|'\n'
DECL|variable|metadata
name|'metadata'
op|'='
op|'{'
string|"'k1'"
op|':'
string|"'1'"
op|','
string|"'k2'"
op|':'
string|"'2'"
op|'}'
op|','
nl|'\n'
op|')'
op|','
nl|'\n'
name|'objects'
op|'.'
name|'Aggregate'
op|'('
nl|'\n'
DECL|variable|id
name|'id'
op|'='
number|'2'
op|','
nl|'\n'
DECL|variable|name
name|'name'
op|'='
string|"'bar'"
op|','
nl|'\n'
DECL|variable|hosts
name|'hosts'
op|'='
op|'['
string|"'fake-host'"
op|']'
op|','
nl|'\n'
DECL|variable|metadata
name|'metadata'
op|'='
op|'{'
string|"'k1'"
op|':'
string|"'3'"
op|','
string|"'k2'"
op|':'
string|"'4'"
op|'}'
op|','
nl|'\n'
op|')'
op|','
nl|'\n'
name|'objects'
op|'.'
name|'Aggregate'
op|'('
nl|'\n'
DECL|variable|id
name|'id'
op|'='
number|'3'
op|','
nl|'\n'
DECL|variable|name
name|'name'
op|'='
string|"'bar'"
op|','
nl|'\n'
DECL|variable|hosts
name|'hosts'
op|'='
op|'['
string|"'fake-host'"
op|']'
op|','
nl|'\n'
DECL|variable|metadata
name|'metadata'
op|'='
op|'{'
string|"'k1'"
op|':'
string|"'6,7'"
op|','
string|"'k2'"
op|':'
string|"'8, 9'"
op|'}'
op|','
nl|'\n'
op|')'
op|','
nl|'\n'
op|']'
newline|'\n'
nl|'\n'
nl|'\n'
DECL|class|TestUtils
name|'class'
name|'TestUtils'
op|'('
name|'test'
op|'.'
name|'NoDBTestCase'
op|')'
op|':'
newline|'\n'
DECL|member|setUp
indent|'    '
name|'def'
name|'setUp'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'super'
op|'('
name|'TestUtils'
op|','
name|'self'
op|')'
op|'.'
name|'setUp'
op|'('
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_aggregate_values_from_key
dedent|''
name|'def'
name|'test_aggregate_values_from_key'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'host_state'
op|'='
name|'fakes'
op|'.'
name|'FakeHostState'
op|'('
nl|'\n'
string|"'fake'"
op|','
string|"'node'"
op|','
op|'{'
string|"'aggregates'"
op|':'
name|'_AGGREGATE_FIXTURES'
op|'}'
op|')'
newline|'\n'
nl|'\n'
name|'values'
op|'='
name|'utils'
op|'.'
name|'aggregate_values_from_key'
op|'('
name|'host_state'
op|','
name|'key_name'
op|'='
string|"'k1'"
op|')'
newline|'\n'
nl|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
name|'set'
op|'('
op|'['
string|"'1'"
op|','
string|"'3'"
op|','
string|"'6,7'"
op|']'
op|')'
op|','
name|'values'
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_aggregate_values_from_key_with_wrong_key
dedent|''
name|'def'
name|'test_aggregate_values_from_key_with_wrong_key'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'host_state'
op|'='
name|'fakes'
op|'.'
name|'FakeHostState'
op|'('
nl|'\n'
string|"'fake'"
op|','
string|"'node'"
op|','
op|'{'
string|"'aggregates'"
op|':'
name|'_AGGREGATE_FIXTURES'
op|'}'
op|')'
newline|'\n'
nl|'\n'
name|'values'
op|'='
name|'utils'
op|'.'
name|'aggregate_values_from_key'
op|'('
name|'host_state'
op|','
name|'key_name'
op|'='
string|"'k3'"
op|')'
newline|'\n'
nl|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
name|'set'
op|'('
op|')'
op|','
name|'values'
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_aggregate_metadata_get_by_host_no_key
dedent|''
name|'def'
name|'test_aggregate_metadata_get_by_host_no_key'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'host_state'
op|'='
name|'fakes'
op|'.'
name|'FakeHostState'
op|'('
nl|'\n'
string|"'fake'"
op|','
string|"'node'"
op|','
op|'{'
string|"'aggregates'"
op|':'
name|'_AGGREGATE_FIXTURES'
op|'}'
op|')'
newline|'\n'
nl|'\n'
name|'metadata'
op|'='
name|'utils'
op|'.'
name|'aggregate_metadata_get_by_host'
op|'('
name|'host_state'
op|')'
newline|'\n'
nl|'\n'
name|'self'
op|'.'
name|'assertIn'
op|'('
string|"'k1'"
op|','
name|'metadata'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
name|'set'
op|'('
op|'['
string|"'1'"
op|','
string|"'3'"
op|','
string|"'7'"
op|','
string|"'6'"
op|']'
op|')'
op|','
name|'metadata'
op|'['
string|"'k1'"
op|']'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertIn'
op|'('
string|"'k2'"
op|','
name|'metadata'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
name|'set'
op|'('
op|'['
string|"'9'"
op|','
string|"'8'"
op|','
string|"'2'"
op|','
string|"'4'"
op|']'
op|')'
op|','
name|'metadata'
op|'['
string|"'k2'"
op|']'
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_aggregate_metadata_get_by_host_with_key
dedent|''
name|'def'
name|'test_aggregate_metadata_get_by_host_with_key'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'host_state'
op|'='
name|'fakes'
op|'.'
name|'FakeHostState'
op|'('
nl|'\n'
string|"'fake'"
op|','
string|"'node'"
op|','
op|'{'
string|"'aggregates'"
op|':'
name|'_AGGREGATE_FIXTURES'
op|'}'
op|')'
newline|'\n'
nl|'\n'
name|'metadata'
op|'='
name|'utils'
op|'.'
name|'aggregate_metadata_get_by_host'
op|'('
name|'host_state'
op|','
string|"'k1'"
op|')'
newline|'\n'
nl|'\n'
name|'self'
op|'.'
name|'assertIn'
op|'('
string|"'k1'"
op|','
name|'metadata'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
name|'set'
op|'('
op|'['
string|"'1'"
op|','
string|"'3'"
op|','
string|"'7'"
op|','
string|"'6'"
op|']'
op|')'
op|','
name|'metadata'
op|'['
string|"'k1'"
op|']'
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_aggregate_metadata_get_by_host_empty_result
dedent|''
name|'def'
name|'test_aggregate_metadata_get_by_host_empty_result'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'host_state'
op|'='
name|'fakes'
op|'.'
name|'FakeHostState'
op|'('
nl|'\n'
string|"'fake'"
op|','
string|"'node'"
op|','
op|'{'
string|"'aggregates'"
op|':'
op|'['
op|']'
op|'}'
op|')'
newline|'\n'
nl|'\n'
name|'metadata'
op|'='
name|'utils'
op|'.'
name|'aggregate_metadata_get_by_host'
op|'('
name|'host_state'
op|','
string|"'k3'"
op|')'
newline|'\n'
nl|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
op|'{'
op|'}'
op|','
name|'metadata'
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_validate_num_values
dedent|''
name|'def'
name|'test_validate_num_values'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'f'
op|'='
name|'utils'
op|'.'
name|'validate_num_values'
newline|'\n'
nl|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
string|'"x"'
op|','
name|'f'
op|'('
name|'set'
op|'('
op|')'
op|','
name|'default'
op|'='
string|'"x"'
op|')'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
number|'1'
op|','
name|'f'
op|'('
name|'set'
op|'('
op|'['
string|'"1"'
op|']'
op|')'
op|','
name|'cast_to'
op|'='
name|'int'
op|')'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
number|'1.0'
op|','
name|'f'
op|'('
name|'set'
op|'('
op|'['
string|'"1"'
op|']'
op|')'
op|','
name|'cast_to'
op|'='
name|'float'
op|')'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
number|'1'
op|','
name|'f'
op|'('
name|'set'
op|'('
op|'['
number|'1'
op|','
number|'2'
op|']'
op|')'
op|','
name|'based_on'
op|'='
name|'min'
op|')'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
number|'2'
op|','
name|'f'
op|'('
name|'set'
op|'('
op|'['
number|'1'
op|','
number|'2'
op|']'
op|')'
op|','
name|'based_on'
op|'='
name|'max'
op|')'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
number|'9'
op|','
name|'f'
op|'('
name|'set'
op|'('
op|'['
string|"'10'"
op|','
string|"'9'"
op|']'
op|')'
op|','
name|'based_on'
op|'='
name|'min'
op|')'
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_instance_uuids_overlap
dedent|''
name|'def'
name|'test_instance_uuids_overlap'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'inst1'
op|'='
name|'objects'
op|'.'
name|'Instance'
op|'('
name|'uuid'
op|'='
string|"'aa'"
op|')'
newline|'\n'
name|'inst2'
op|'='
name|'objects'
op|'.'
name|'Instance'
op|'('
name|'uuid'
op|'='
string|"'bb'"
op|')'
newline|'\n'
name|'instances'
op|'='
op|'['
name|'inst1'
op|','
name|'inst2'
op|']'
newline|'\n'
name|'host_state'
op|'='
name|'fakes'
op|'.'
name|'FakeHostState'
op|'('
string|"'host1'"
op|','
string|"'node1'"
op|','
op|'{'
op|'}'
op|')'
newline|'\n'
name|'host_state'
op|'.'
name|'instances'
op|'='
op|'{'
name|'instance'
op|'.'
name|'uuid'
op|':'
name|'instance'
nl|'\n'
name|'for'
name|'instance'
name|'in'
name|'instances'
op|'}'
newline|'\n'
name|'self'
op|'.'
name|'assertTrue'
op|'('
name|'utils'
op|'.'
name|'instance_uuids_overlap'
op|'('
name|'host_state'
op|','
op|'['
string|"'aa'"
op|']'
op|')'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertFalse'
op|'('
name|'utils'
op|'.'
name|'instance_uuids_overlap'
op|'('
name|'host_state'
op|','
op|'['
string|"'zz'"
op|']'
op|')'
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_other_types_on_host
dedent|''
name|'def'
name|'test_other_types_on_host'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'inst1'
op|'='
name|'objects'
op|'.'
name|'Instance'
op|'('
name|'uuid'
op|'='
string|"'aa'"
op|','
name|'instance_type_id'
op|'='
number|'1'
op|')'
newline|'\n'
name|'host_state'
op|'='
name|'fakes'
op|'.'
name|'FakeHostState'
op|'('
string|"'host1'"
op|','
string|"'node1'"
op|','
op|'{'
op|'}'
op|')'
newline|'\n'
name|'host_state'
op|'.'
name|'instances'
op|'='
op|'{'
name|'inst1'
op|'.'
name|'uuid'
op|':'
name|'inst1'
op|'}'
newline|'\n'
name|'self'
op|'.'
name|'assertFalse'
op|'('
name|'utils'
op|'.'
name|'other_types_on_host'
op|'('
name|'host_state'
op|','
number|'1'
op|')'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertTrue'
op|'('
name|'utils'
op|'.'
name|'other_types_on_host'
op|'('
name|'host_state'
op|','
number|'2'
op|')'
op|')'
newline|'\n'
dedent|''
dedent|''
endmarker|''
end_unit
