text: begin_unit
  comment|'# Copyright 2011-2012 OpenStack Foundation'
  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'
  string|'"""\nTests For weights.\n"""'
  newline|'\n'
  nl|'\n'
  name|'import'
  name|'mock'
  newline|'\n'
  nl|'\n'
  name|'from'
  name|'nova'
  op|'.'
  name|'scheduler'
  name|'import'
  name|'weights'
  name|'as'
  name|'scheduler_weights'
  newline|'\n'
  name|'from'
  name|'nova'
  op|'.'
  name|'scheduler'
  op|'.'
  name|'weights'
  name|'import'
  name|'ram'
  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'
  name|'from'
  name|'nova'
  name|'import'
  name|'weights'
  newline|'\n'
  nl|'\n'
  nl|'\n'
  DECL|class|TestWeigher
  name|'class'
  name|'TestWeigher'
  op|'('
  name|'test'
  op|'.'
  name|'NoDBTestCase'
  op|')'
  op|':'
  newline|'\n'
  DECL|member|test_no_multiplier
  indent|'    '
  name|'def'
  name|'test_no_multiplier'
  op|'('
  name|'self'
  op|')'
  op|':'
  newline|'\n'
  DECL|class|FakeWeigher
  indent|'        '
  name|'class'
  name|'FakeWeigher'
  op|'('
  name|'weights'
  op|'.'
  name|'BaseWeigher'
  op|')'
  op|':'
  newline|'\n'
  DECL|member|_weigh_object
  indent|'            '
  name|'def'
  name|'_weigh_object'
  op|'('
  name|'self'
  op|','
  op|'*'
  name|'args'
  op|','
  op|'**'
  name|'kwargs'
  op|')'
  op|':'
  newline|'\n'
  indent|'                '
  name|'pass'
  newline|'\n'
  nl|'\n'
  dedent|''
  dedent|''
  name|'self'
  op|'.'
  name|'assertEqual'
  op|'('
  number|'1.0'
  op|','
  nl|'\n'
  name|'FakeWeigher'
  op|'('
  op|')'
  op|'.'
  name|'weight_multiplier'
  op|'('
  op|')'
  op|')'
  newline|'\n'
  nl|'\n'
  DECL|member|test_no_weight_object
  dedent|''
  name|'def'
  name|'test_no_weight_object'
  op|'('
  name|'self'
  op|')'
  op|':'
  newline|'\n'
  DECL|class|FakeWeigher
  indent|'        '
  name|'class'
  name|'FakeWeigher'
  op|'('
  name|'weights'
  op|'.'
  name|'BaseWeigher'
  op|')'
  op|':'
  newline|'\n'
  DECL|member|weight_multiplier
  indent|'            '
  name|'def'
  name|'weight_multiplier'
  op|'('
  name|'self'
  op|','
  op|'*'
  name|'args'
  op|','
  op|'**'
  name|'kwargs'
  op|')'
  op|':'
  newline|'\n'
  indent|'                '
  name|'pass'
  newline|'\n'
  dedent|''
  dedent|''
  name|'self'
  op|'.'
  name|'assertRaises'
  op|'('
  name|'TypeError'
  op|','
  nl|'\n'
  name|'FakeWeigher'
  op|')'
  newline|'\n'
  nl|'\n'
  DECL|member|test_normalization
  dedent|''
  name|'def'
  name|'test_normalization'
  op|'('
  name|'self'
  op|')'
  op|':'
  newline|'\n'
  comment|'# weight_list, expected_result, minval, maxval'
  nl|'\n'
  indent|'        '
  name|'map_'
  op|'='
  op|'('
  nl|'\n'
  op|'('
  op|'('
  op|')'
  op|','
  op|'('
  op|')'
  op|','
  name|'None'
  op|','
  name|'None'
  op|')'
  op|','
  nl|'\n'
  op|'('
  op|'('
  number|'0.0'
  op|','
  number|'0.0'
  op|')'
  op|','
  op|'('
  number|'0.0'
  op|','
  number|'0.0'
  op|')'
  op|','
  name|'None'
  op|','
  name|'None'
  op|')'
  op|','
  nl|'\n'
  op|'('
  op|'('
  number|'1.0'
  op|','
  number|'1.0'
  op|')'
  op|','
  op|'('
  number|'0.0'
  op|','
  number|'0.0'
  op|')'
  op|','
  name|'None'
  op|','
  name|'None'
  op|')'
  op|','
  nl|'\n'
  nl|'\n'
  op|'('
  op|'('
  number|'20.0'
  op|','
  number|'50.0'
  op|')'
  op|','
  op|'('
  number|'0.0'
  op|','
  number|'1.0'
  op|')'
  op|','
  name|'None'
  op|','
  name|'None'
  op|')'
  op|','
  nl|'\n'
  op|'('
  op|'('
  number|'20.0'
  op|','
  number|'50.0'
  op|')'
  op|','
  op|'('
  number|'0.0'
  op|','
  number|'0.375'
  op|')'
  op|','
  name|'None'
  op|','
  number|'100.0'
  op|')'
  op|','
  nl|'\n'
  op|'('
  op|'('
  number|'20.0'
  op|','
  number|'50.0'
  op|')'
  op|','
  op|'('
  number|'0.4'
  op|','
  number|'1.0'
  op|')'
  op|','
  number|'0.0'
  op|','
  name|'None'
  op|')'
  op|','
  nl|'\n'
  op|'('
  op|'('
  number|'20.0'
  op|','
  number|'50.0'
  op|')'
  op|','
  op|'('
  number|'0.2'
  op|','
  number|'0.5'
  op|')'
  op|','
  number|'0.0'
  op|','
  number|'100.0'
  op|')'
  op|','
  nl|'\n'
  op|')'
  newline|'\n'
  name|'for'
  name|'seq'
  op|','
  name|'result'
  op|','
  name|'minval'
  op|','
  name|'maxval'
  name|'in'
  name|'map_'
  op|':'
  newline|'\n'
  indent|'            '
  name|'ret'
  op|'='
  name|'weights'
  op|'.'
  name|'normalize'
  op|'('
  name|'seq'
  op|','
  name|'minval'
  op|'='
  name|'minval'
  op|','
  name|'maxval'
  op|'='
  name|'maxval'
  op|')'
  newline|'\n'
  name|'self'
  op|'.'
  name|'assertEqual'
  op|'('
  name|'tuple'
  op|'('
  name|'ret'
  op|')'
  op|','
  name|'result'
  op|')'
  newline|'\n'
  nl|'\n'
  dedent|''
  dedent|''
  op|'@'
  name|'mock'
  op|'.'
  name|'patch'
  op|'('
  string|"'nova.weights.BaseWeigher.weigh_objects'"
  op|')'
  newline|'\n'
  DECL|member|test_only_one_host
  name|'def'
  name|'test_only_one_host'
  op|'('
  name|'self'
  op|','
  name|'mock_weigh'
  op|')'
  op|':'
  newline|'\n'
  indent|'        '
  name|'host_values'
  op|'='
  op|'['
  nl|'\n'
  op|'('
  string|"'host1'"
  op|','
  string|"'node1'"
  op|','
  op|'{'
  string|"'free_ram_mb'"
  op|':'
  number|'512'
  op|'}'
  op|')'
  op|','
  nl|'\n'
  op|']'
  newline|'\n'
  name|'hostinfo'
  op|'='
  op|'['
  name|'fakes'
  op|'.'
  name|'FakeHostState'
  op|'('
  name|'host'
  op|','
  name|'node'
  op|','
  name|'values'
  op|')'
  nl|'\n'
  name|'for'
  name|'host'
  op|','
  name|'node'
  op|','
  name|'values'
  name|'in'
  name|'host_values'
  op|']'
  newline|'\n'
  nl|'\n'
  name|'weight_handler'
  op|'='
  name|'scheduler_weights'
  op|'.'
  name|'HostWeightHandler'
  op|'('
  op|')'
  newline|'\n'
  name|'weighers'
  op|'='
  op|'['
  name|'ram'
  op|'.'
  name|'RAMWeigher'
  op|'('
  op|')'
  op|']'
  newline|'\n'
  name|'weighed_host'
  op|'='
  name|'weight_handler'
  op|'.'
  name|'get_weighed_objects'
  op|'('
  name|'weighers'
  op|','
  nl|'\n'
  name|'hostinfo'
  op|','
  op|'{'
  op|'}'
  op|')'
  newline|'\n'
  name|'self'
  op|'.'
  name|'assertEqual'
  op|'('
  number|'1'
  op|','
  name|'len'
  op|'('
  name|'weighed_host'
  op|')'
  op|')'
  newline|'\n'
  name|'self'
  op|'.'
  name|'assertEqual'
  op|'('
  string|"'host1'"
  op|','
  name|'weighed_host'
  op|'['
  number|'0'
  op|']'
  op|'.'
  name|'obj'
  op|'.'
  name|'host'
  op|')'
  newline|'\n'
  name|'self'
  op|'.'
  name|'assertFalse'
  op|'('
  name|'mock_weigh'
  op|'.'
  name|'called'
  op|')'
  newline|'\n'
  dedent|''
  dedent|''
  endmarker|''
  end_unit
  