<reponame>bopopescu/nova-token<filename>nova/tests/unit/objects/test_flavor.py
begin_unit
comment|'#    Copyright 2013 Red Hat, Inc.'
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|'datetime'
newline|'\n'
nl|'\n'
name|'import'
name|'mock'
newline|'\n'
name|'from'
name|'oslo_db'
name|'import'
name|'exception'
name|'as'
name|'db_exc'
newline|'\n'
nl|'\n'
name|'from'
name|'nova'
name|'import'
name|'db'
newline|'\n'
name|'from'
name|'nova'
op|'.'
name|'db'
op|'.'
name|'sqlalchemy'
name|'import'
name|'api'
name|'as'
name|'db_api'
newline|'\n'
name|'from'
name|'nova'
op|'.'
name|'db'
op|'.'
name|'sqlalchemy'
name|'import'
name|'api_models'
newline|'\n'
name|'from'
name|'nova'
name|'import'
name|'exception'
newline|'\n'
name|'from'
name|'nova'
name|'import'
name|'objects'
newline|'\n'
name|'from'
name|'nova'
op|'.'
name|'objects'
name|'import'
name|'flavor'
name|'as'
name|'flavor_obj'
newline|'\n'
name|'from'
name|'nova'
op|'.'
name|'tests'
op|'.'
name|'unit'
op|'.'
name|'objects'
name|'import'
name|'test_objects'
newline|'\n'
nl|'\n'
nl|'\n'
DECL|variable|fake_flavor
name|'fake_flavor'
op|'='
op|'{'
nl|'\n'
string|"'created_at'"
op|':'
name|'None'
op|','
nl|'\n'
string|"'updated_at'"
op|':'
name|'None'
op|','
nl|'\n'
string|"'deleted_at'"
op|':'
name|'None'
op|','
nl|'\n'
string|"'deleted'"
op|':'
number|'0'
op|','
nl|'\n'
string|"'id'"
op|':'
number|'1'
op|','
nl|'\n'
string|"'name'"
op|':'
string|"'m1.foo'"
op|','
nl|'\n'
string|"'memory_mb'"
op|':'
number|'1024'
op|','
nl|'\n'
string|"'vcpus'"
op|':'
number|'4'
op|','
nl|'\n'
string|"'root_gb'"
op|':'
number|'20'
op|','
nl|'\n'
string|"'ephemeral_gb'"
op|':'
number|'0'
op|','
nl|'\n'
string|"'flavorid'"
op|':'
string|"'m1.foo'"
op|','
nl|'\n'
string|"'swap'"
op|':'
number|'0'
op|','
nl|'\n'
string|"'rxtx_factor'"
op|':'
number|'1.0'
op|','
nl|'\n'
string|"'vcpu_weight'"
op|':'
number|'1'
op|','
nl|'\n'
string|"'disabled'"
op|':'
name|'False'
op|','
nl|'\n'
string|"'is_public'"
op|':'
name|'True'
op|','
nl|'\n'
string|"'extra_specs'"
op|':'
op|'{'
string|"'foo'"
op|':'
string|"'bar'"
op|'}'
op|','
nl|'\n'
op|'}'
newline|'\n'
nl|'\n'
nl|'\n'
DECL|variable|fake_api_flavor
name|'fake_api_flavor'
op|'='
op|'{'
nl|'\n'
string|"'created_at'"
op|':'
name|'None'
op|','
nl|'\n'
string|"'updated_at'"
op|':'
name|'None'
op|','
nl|'\n'
string|"'id'"
op|':'
number|'1'
op|','
nl|'\n'
string|"'name'"
op|':'
string|"'m1.foo'"
op|','
nl|'\n'
string|"'memory_mb'"
op|':'
number|'1024'
op|','
nl|'\n'
string|"'vcpus'"
op|':'
number|'4'
op|','
nl|'\n'
string|"'root_gb'"
op|':'
number|'20'
op|','
nl|'\n'
string|"'ephemeral_gb'"
op|':'
number|'0'
op|','
nl|'\n'
string|"'flavorid'"
op|':'
string|"'m1.foo'"
op|','
nl|'\n'
string|"'swap'"
op|':'
number|'0'
op|','
nl|'\n'
string|"'rxtx_factor'"
op|':'
number|'1.0'
op|','
nl|'\n'
string|"'vcpu_weight'"
op|':'
number|'1'
op|','
nl|'\n'
string|"'disabled'"
op|':'
name|'False'
op|','
nl|'\n'
string|"'is_public'"
op|':'
name|'True'
op|','
nl|'\n'
string|"'extra_specs'"
op|':'
op|'{'
string|"'foo'"
op|':'
string|"'bar'"
op|'}'
op|','
nl|'\n'
op|'}'
newline|'\n'
nl|'\n'
nl|'\n'
DECL|class|_TestFlavor
name|'class'
name|'_TestFlavor'
op|'('
name|'object'
op|')'
op|':'
newline|'\n'
indent|'    '
op|'@'
name|'staticmethod'
newline|'\n'
DECL|member|_compare
name|'def'
name|'_compare'
op|'('
name|'test'
op|','
name|'db'
op|','
name|'obj'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'for'
name|'field'
op|','
name|'value'
name|'in'
name|'db'
op|'.'
name|'items'
op|'('
op|')'
op|':'
newline|'\n'
comment|'# NOTE(danms): The datetimes on SQLA models are tz-unaware,'
nl|'\n'
comment|"# but the object has tz-aware datetimes. If we're comparing"
nl|'\n'
comment|'# a model to an object (as opposed to a fake dict), just'
nl|'\n'
comment|'# ignore the datetimes in the comparison.'
nl|'\n'
indent|'            '
name|'if'
op|'('
name|'isinstance'
op|'('
name|'db'
op|','
name|'api_models'
op|'.'
name|'API_BASE'
op|')'
name|'and'
nl|'\n'
name|'isinstance'
op|'('
name|'value'
op|','
name|'datetime'
op|'.'
name|'datetime'
op|')'
op|')'
op|':'
newline|'\n'
indent|'                '
name|'continue'
newline|'\n'
dedent|''
name|'test'
op|'.'
name|'assertEqual'
op|'('
name|'db'
op|'['
name|'field'
op|']'
op|','
name|'obj'
op|'['
name|'field'
op|']'
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_get_by_id
dedent|''
dedent|''
name|'def'
name|'test_get_by_id'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'with'
name|'mock'
op|'.'
name|'patch'
op|'.'
name|'object'
op|'('
name|'db'
op|','
string|"'flavor_get'"
op|')'
name|'as'
name|'get'
op|':'
newline|'\n'
indent|'            '
name|'get'
op|'.'
name|'return_value'
op|'='
name|'fake_flavor'
newline|'\n'
name|'flavor'
op|'='
name|'flavor_obj'
op|'.'
name|'Flavor'
op|'.'
name|'get_by_id'
op|'('
name|'self'
op|'.'
name|'context'
op|','
number|'100'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'_compare'
op|'('
name|'self'
op|','
name|'fake_flavor'
op|','
name|'flavor'
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_get_by_name
dedent|''
dedent|''
name|'def'
name|'test_get_by_name'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'with'
name|'mock'
op|'.'
name|'patch'
op|'.'
name|'object'
op|'('
name|'db'
op|','
string|"'flavor_get_by_name'"
op|')'
name|'as'
name|'get_by_name'
op|':'
newline|'\n'
indent|'            '
name|'get_by_name'
op|'.'
name|'return_value'
op|'='
name|'fake_flavor'
newline|'\n'
name|'flavor'
op|'='
name|'flavor_obj'
op|'.'
name|'Flavor'
op|'.'
name|'get_by_name'
op|'('
name|'self'
op|'.'
name|'context'
op|','
string|"'m1.legacy'"
op|')'
newline|'\n'
name|'self'
op|'.'
name|'_compare'
op|'('
name|'self'
op|','
name|'fake_flavor'
op|','
name|'flavor'
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_get_by_flavor_id
dedent|''
dedent|''
name|'def'
name|'test_get_by_flavor_id'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'with'
name|'mock'
op|'.'
name|'patch'
op|'.'
name|'object'
op|'('
name|'db'
op|','
string|"'flavor_get_by_flavor_id'"
op|')'
name|'as'
name|'get_by_id'
op|':'
newline|'\n'
indent|'            '
name|'get_by_id'
op|'.'
name|'return_value'
op|'='
name|'fake_flavor'
newline|'\n'
name|'flavor'
op|'='
name|'flavor_obj'
op|'.'
name|'Flavor'
op|'.'
name|'get_by_flavor_id'
op|'('
name|'self'
op|'.'
name|'context'
op|','
nl|'\n'
string|"'m1.legacy'"
op|')'
newline|'\n'
name|'self'
op|'.'
name|'_compare'
op|'('
name|'self'
op|','
name|'fake_flavor'
op|','
name|'flavor'
op|')'
newline|'\n'
nl|'\n'
dedent|''
dedent|''
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.Flavor._flavor_get_from_db'"
op|')'
newline|'\n'
DECL|member|test_api_get_by_id_from_api
name|'def'
name|'test_api_get_by_id_from_api'
op|'('
name|'self'
op|','
name|'mock_get'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'mock_get'
op|'.'
name|'return_value'
op|'='
name|'fake_api_flavor'
newline|'\n'
name|'flavor'
op|'='
name|'flavor_obj'
op|'.'
name|'Flavor'
op|'.'
name|'get_by_id'
op|'('
name|'self'
op|'.'
name|'context'
op|','
number|'1'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'_compare'
op|'('
name|'self'
op|','
name|'fake_api_flavor'
op|','
name|'flavor'
op|')'
newline|'\n'
name|'mock_get'
op|'.'
name|'assert_called_once_with'
op|'('
name|'self'
op|'.'
name|'context'
op|','
number|'1'
op|')'
newline|'\n'
nl|'\n'
dedent|''
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.Flavor._flavor_get_by_name_from_db'"
op|')'
newline|'\n'
DECL|member|test_get_by_name_from_api
name|'def'
name|'test_get_by_name_from_api'
op|'('
name|'self'
op|','
name|'mock_get'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'mock_get'
op|'.'
name|'return_value'
op|'='
name|'fake_api_flavor'
newline|'\n'
name|'flavor'
op|'='
name|'flavor_obj'
op|'.'
name|'Flavor'
op|'.'
name|'get_by_name'
op|'('
name|'self'
op|'.'
name|'context'
op|','
string|"'m1.foo'"
op|')'
newline|'\n'
name|'self'
op|'.'
name|'_compare'
op|'('
name|'self'
op|','
name|'fake_api_flavor'
op|','
name|'flavor'
op|')'
newline|'\n'
name|'mock_get'
op|'.'
name|'assert_called_once_with'
op|'('
name|'self'
op|'.'
name|'context'
op|','
string|"'m1.foo'"
op|')'
newline|'\n'
nl|'\n'
dedent|''
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.Flavor._flavor_get_by_flavor_id_from_db'"
op|')'
newline|'\n'
DECL|member|test_get_by_flavor_id_from_api
name|'def'
name|'test_get_by_flavor_id_from_api'
op|'('
name|'self'
op|','
name|'mock_get'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'mock_get'
op|'.'
name|'return_value'
op|'='
name|'fake_api_flavor'
newline|'\n'
name|'flavor'
op|'='
name|'flavor_obj'
op|'.'
name|'Flavor'
op|'.'
name|'get_by_flavor_id'
op|'('
name|'self'
op|'.'
name|'context'
op|','
string|"'m1.foo'"
op|')'
newline|'\n'
name|'self'
op|'.'
name|'_compare'
op|'('
name|'self'
op|','
name|'fake_api_flavor'
op|','
name|'flavor'
op|')'
newline|'\n'
name|'mock_get'
op|'.'
name|'assert_called_once_with'
op|'('
name|'self'
op|'.'
name|'context'
op|','
string|"'m1.foo'"
op|')'
newline|'\n'
nl|'\n'
dedent|''
op|'@'
name|'staticmethod'
newline|'\n'
op|'@'
name|'db_api'
op|'.'
name|'api_context_manager'
op|'.'
name|'writer'
newline|'\n'
DECL|member|_create_api_flavor
name|'def'
name|'_create_api_flavor'
op|'('
name|'context'
op|','
name|'altid'
op|'='
name|'None'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'fake_db_flavor'
op|'='
name|'dict'
op|'('
name|'fake_api_flavor'
op|')'
newline|'\n'
name|'del'
name|'fake_db_flavor'
op|'['
string|"'extra_specs'"
op|']'
newline|'\n'
name|'del'
name|'fake_db_flavor'
op|'['
string|"'id'"
op|']'
newline|'\n'
name|'flavor'
op|'='
name|'api_models'
op|'.'
name|'Flavors'
op|'('
op|')'
newline|'\n'
name|'flavor'
op|'.'
name|'update'
op|'('
name|'fake_db_flavor'
op|')'
newline|'\n'
name|'if'
name|'altid'
op|':'
newline|'\n'
indent|'            '
name|'flavor'
op|'.'
name|'update'
op|'('
op|'{'
string|"'flavorid'"
op|':'
name|'altid'
op|','
nl|'\n'
string|"'name'"
op|':'
name|'altid'
op|'}'
op|')'
newline|'\n'
dedent|''
name|'flavor'
op|'.'
name|'save'
op|'('
name|'context'
op|'.'
name|'session'
op|')'
newline|'\n'
nl|'\n'
name|'fake_db_extra_spec'
op|'='
op|'{'
string|"'flavor_id'"
op|':'
name|'flavor'
op|'['
string|"'id'"
op|']'
op|','
nl|'\n'
string|"'key'"
op|':'
string|"'foo'"
op|','
string|"'value'"
op|':'
string|"'bar'"
op|'}'
newline|'\n'
name|'flavor_es'
op|'='
name|'api_models'
op|'.'
name|'FlavorExtraSpecs'
op|'('
op|')'
newline|'\n'
name|'flavor_es'
op|'.'
name|'update'
op|'('
name|'fake_db_extra_spec'
op|')'
newline|'\n'
name|'flavor_es'
op|'.'
name|'save'
op|'('
name|'context'
op|'.'
name|'session'
op|')'
newline|'\n'
nl|'\n'
name|'return'
name|'flavor'
newline|'\n'
nl|'\n'
DECL|member|test_get_by_id_from_db
dedent|''
name|'def'
name|'test_get_by_id_from_db'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'db_flavor'
op|'='
name|'self'
op|'.'
name|'_create_api_flavor'
op|'('
name|'self'
op|'.'
name|'context'
op|')'
newline|'\n'
name|'flavor'
op|'='
name|'objects'
op|'.'
name|'Flavor'
op|'.'
name|'get_by_id'
op|'('
name|'self'
op|'.'
name|'context'
op|','
name|'db_flavor'
op|'['
string|"'id'"
op|']'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'_compare'
op|'('
name|'self'
op|','
name|'db_flavor'
op|','
name|'flavor'
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_get_by_name_from_db
dedent|''
name|'def'
name|'test_get_by_name_from_db'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'db_flavor'
op|'='
name|'self'
op|'.'
name|'_create_api_flavor'
op|'('
name|'self'
op|'.'
name|'context'
op|')'
newline|'\n'
name|'flavor'
op|'='
name|'objects'
op|'.'
name|'Flavor'
op|'.'
name|'get_by_name'
op|'('
name|'self'
op|'.'
name|'context'
op|','
name|'db_flavor'
op|'['
string|"'name'"
op|']'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'_compare'
op|'('
name|'self'
op|','
name|'db_flavor'
op|','
name|'flavor'
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_get_by_flavor_id_from_db
dedent|''
name|'def'
name|'test_get_by_flavor_id_from_db'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'db_flavor'
op|'='
name|'self'
op|'.'
name|'_create_api_flavor'
op|'('
name|'self'
op|'.'
name|'context'
op|')'
newline|'\n'
name|'flavor'
op|'='
name|'objects'
op|'.'
name|'Flavor'
op|'.'
name|'get_by_flavor_id'
op|'('
name|'self'
op|'.'
name|'context'
op|','
nl|'\n'
name|'db_flavor'
op|'['
string|"'flavorid'"
op|']'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'_compare'
op|'('
name|'self'
op|','
name|'db_flavor'
op|','
name|'flavor'
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_add_access
dedent|''
name|'def'
name|'test_add_access'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'elevated'
op|'='
name|'self'
op|'.'
name|'context'
op|'.'
name|'elevated'
op|'('
op|')'
newline|'\n'
name|'flavor'
op|'='
name|'flavor_obj'
op|'.'
name|'Flavor'
op|'('
name|'context'
op|'='
name|'elevated'
op|','
name|'id'
op|'='
number|'12345'
op|','
name|'flavorid'
op|'='
string|"'123'"
op|')'
newline|'\n'
name|'with'
name|'mock'
op|'.'
name|'patch'
op|'.'
name|'object'
op|'('
name|'db'
op|','
string|"'flavor_access_add'"
op|')'
name|'as'
name|'add'
op|':'
newline|'\n'
indent|'            '
name|'flavor'
op|'.'
name|'add_access'
op|'('
string|"'456'"
op|')'
newline|'\n'
name|'add'
op|'.'
name|'assert_called_once_with'
op|'('
name|'elevated'
op|','
string|"'123'"
op|','
string|"'456'"
op|')'
newline|'\n'
nl|'\n'
dedent|''
dedent|''
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.db.flavor_access_add'"
op|')'
newline|'\n'
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.Flavor._flavor_add_project'"
op|')'
newline|'\n'
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.Flavor.in_api'"
op|','
name|'new'
op|'='
name|'True'
op|')'
newline|'\n'
DECL|member|test_add_access_api
name|'def'
name|'test_add_access_api'
op|'('
name|'self'
op|','
name|'mock_api_add'
op|','
name|'mock_main_add'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'elevated'
op|'='
name|'self'
op|'.'
name|'context'
op|'.'
name|'elevated'
op|'('
op|')'
newline|'\n'
name|'flavor'
op|'='
name|'flavor_obj'
op|'.'
name|'Flavor'
op|'('
name|'context'
op|'='
name|'elevated'
op|','
name|'id'
op|'='
number|'12345'
op|','
name|'flavorid'
op|'='
string|"'123'"
op|')'
newline|'\n'
name|'flavor'
op|'.'
name|'add_access'
op|'('
string|"'456'"
op|')'
newline|'\n'
name|'mock_api_add'
op|'.'
name|'assert_called_once_with'
op|'('
name|'elevated'
op|','
number|'12345'
op|','
string|"'456'"
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertFalse'
op|'('
name|'mock_main_add'
op|'.'
name|'called'
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_add_access_with_dirty_projects
dedent|''
name|'def'
name|'test_add_access_with_dirty_projects'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'flavor'
op|'='
name|'flavor_obj'
op|'.'
name|'Flavor'
op|'('
name|'context'
op|'='
name|'self'
op|'.'
name|'context'
op|','
name|'projects'
op|'='
op|'['
string|"'1'"
op|']'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertRaises'
op|'('
name|'exception'
op|'.'
name|'ObjectActionError'
op|','
nl|'\n'
name|'flavor'
op|'.'
name|'add_access'
op|','
string|"'2'"
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_remove_access
dedent|''
name|'def'
name|'test_remove_access'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'elevated'
op|'='
name|'self'
op|'.'
name|'context'
op|'.'
name|'elevated'
op|'('
op|')'
newline|'\n'
name|'flavor'
op|'='
name|'flavor_obj'
op|'.'
name|'Flavor'
op|'('
name|'context'
op|'='
name|'elevated'
op|','
name|'id'
op|'='
number|'12345'
op|','
name|'flavorid'
op|'='
string|"'123'"
op|')'
newline|'\n'
name|'with'
name|'mock'
op|'.'
name|'patch'
op|'.'
name|'object'
op|'('
name|'db'
op|','
string|"'flavor_access_remove'"
op|')'
name|'as'
name|'remove'
op|':'
newline|'\n'
indent|'            '
name|'flavor'
op|'.'
name|'remove_access'
op|'('
string|"'456'"
op|')'
newline|'\n'
name|'remove'
op|'.'
name|'assert_called_once_with'
op|'('
name|'elevated'
op|','
string|"'123'"
op|','
string|"'456'"
op|')'
newline|'\n'
nl|'\n'
dedent|''
dedent|''
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.db.flavor_access_add'"
op|')'
newline|'\n'
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.Flavor._flavor_del_project'"
op|')'
newline|'\n'
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.Flavor.in_api'"
op|','
name|'new'
op|'='
name|'True'
op|')'
newline|'\n'
DECL|member|test_remove_access_api
name|'def'
name|'test_remove_access_api'
op|'('
name|'self'
op|','
name|'mock_api_del'
op|','
name|'mock_main_del'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'elevated'
op|'='
name|'self'
op|'.'
name|'context'
op|'.'
name|'elevated'
op|'('
op|')'
newline|'\n'
name|'flavor'
op|'='
name|'flavor_obj'
op|'.'
name|'Flavor'
op|'('
name|'context'
op|'='
name|'elevated'
op|','
name|'id'
op|'='
number|'12345'
op|','
name|'flavorid'
op|'='
string|"'123'"
op|')'
newline|'\n'
name|'flavor'
op|'.'
name|'remove_access'
op|'('
string|"'456'"
op|')'
newline|'\n'
name|'mock_api_del'
op|'.'
name|'assert_called_once_with'
op|'('
name|'elevated'
op|','
number|'12345'
op|','
string|"'456'"
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertFalse'
op|'('
name|'mock_main_del'
op|'.'
name|'called'
op|')'
newline|'\n'
nl|'\n'
dedent|''
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.Flavor._flavor_create'"
op|')'
newline|'\n'
DECL|member|test_create
name|'def'
name|'test_create'
op|'('
name|'self'
op|','
name|'mock_create'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'mock_create'
op|'.'
name|'return_value'
op|'='
name|'fake_api_flavor'
newline|'\n'
nl|'\n'
name|'flavor'
op|'='
name|'flavor_obj'
op|'.'
name|'Flavor'
op|'('
name|'context'
op|'='
name|'self'
op|'.'
name|'context'
op|')'
newline|'\n'
name|'flavor'
op|'.'
name|'name'
op|'='
string|"'m1.foo'"
newline|'\n'
name|'flavor'
op|'.'
name|'extra_specs'
op|'='
name|'fake_flavor'
op|'['
string|"'extra_specs'"
op|']'
newline|'\n'
name|'flavor'
op|'.'
name|'create'
op|'('
op|')'
newline|'\n'
nl|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
name|'self'
op|'.'
name|'context'
op|','
name|'flavor'
op|'.'
name|'_context'
op|')'
newline|'\n'
comment|'# NOTE(danms): Orphan this to avoid lazy-loads'
nl|'\n'
name|'flavor'
op|'.'
name|'_context'
op|'='
name|'None'
newline|'\n'
name|'self'
op|'.'
name|'_compare'
op|'('
name|'self'
op|','
name|'fake_flavor'
op|','
name|'flavor'
op|')'
newline|'\n'
nl|'\n'
dedent|''
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.Flavor._flavor_create'"
op|')'
newline|'\n'
DECL|member|test_create_with_projects
name|'def'
name|'test_create_with_projects'
op|'('
name|'self'
op|','
name|'mock_create'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'context'
op|'='
name|'self'
op|'.'
name|'context'
op|'.'
name|'elevated'
op|'('
op|')'
newline|'\n'
name|'flavor'
op|'='
name|'flavor_obj'
op|'.'
name|'Flavor'
op|'('
name|'context'
op|'='
name|'context'
op|')'
newline|'\n'
name|'flavor'
op|'.'
name|'name'
op|'='
string|"'m1.foo'"
newline|'\n'
name|'flavor'
op|'.'
name|'extra_specs'
op|'='
name|'fake_flavor'
op|'['
string|"'extra_specs'"
op|']'
newline|'\n'
name|'flavor'
op|'.'
name|'projects'
op|'='
op|'['
string|"'project-1'"
op|','
string|"'project-2'"
op|']'
newline|'\n'
nl|'\n'
name|'db_flavor'
op|'='
name|'dict'
op|'('
name|'fake_flavor'
op|','
nl|'\n'
name|'projects'
op|'='
op|'['
op|'{'
string|"'project_id'"
op|':'
name|'pid'
op|'}'
nl|'\n'
name|'for'
name|'pid'
name|'in'
name|'flavor'
op|'.'
name|'projects'
op|']'
op|')'
newline|'\n'
name|'mock_create'
op|'.'
name|'return_value'
op|'='
name|'db_flavor'
newline|'\n'
name|'flavor'
op|'.'
name|'create'
op|'('
op|')'
newline|'\n'
nl|'\n'
name|'mock_create'
op|'.'
name|'assert_called_once_with'
op|'('
nl|'\n'
name|'context'
op|','
op|'{'
string|"'name'"
op|':'
string|"'m1.foo'"
op|','
nl|'\n'
string|"'extra_specs'"
op|':'
name|'fake_flavor'
op|'['
string|"'extra_specs'"
op|']'
op|','
nl|'\n'
string|"'projects'"
op|':'
op|'['
string|"'project-1'"
op|','
string|"'project-2'"
op|']'
op|'}'
op|')'
newline|'\n'
nl|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
name|'context'
op|','
name|'flavor'
op|'.'
name|'_context'
op|')'
newline|'\n'
comment|'# NOTE(danms): Orphan this to avoid lazy-loads'
nl|'\n'
name|'flavor'
op|'.'
name|'_context'
op|'='
name|'None'
newline|'\n'
name|'self'
op|'.'
name|'_compare'
op|'('
name|'self'
op|','
name|'fake_flavor'
op|','
name|'flavor'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
op|'['
string|"'project-1'"
op|','
string|"'project-2'"
op|']'
op|','
name|'flavor'
op|'.'
name|'projects'
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_create_with_id
dedent|''
name|'def'
name|'test_create_with_id'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'flavor'
op|'='
name|'flavor_obj'
op|'.'
name|'Flavor'
op|'('
name|'context'
op|'='
name|'self'
op|'.'
name|'context'
op|','
name|'id'
op|'='
number|'123'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertRaises'
op|'('
name|'exception'
op|'.'
name|'ObjectActionError'
op|','
name|'flavor'
op|'.'
name|'create'
op|')'
newline|'\n'
nl|'\n'
dedent|''
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.db.sqlalchemy.api_models.Flavors'"
op|')'
newline|'\n'
DECL|member|test_create_duplicate
name|'def'
name|'test_create_duplicate'
op|'('
name|'self'
op|','
name|'mock_flavors'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'mock_flavors'
op|'.'
name|'return_value'
op|'.'
name|'save'
op|'.'
name|'side_effect'
op|'='
name|'db_exc'
op|'.'
name|'DBDuplicateEntry'
newline|'\n'
name|'fields'
op|'='
name|'dict'
op|'('
name|'fake_api_flavor'
op|')'
newline|'\n'
name|'del'
name|'fields'
op|'['
string|"'id'"
op|']'
newline|'\n'
name|'flavor'
op|'='
name|'objects'
op|'.'
name|'Flavor'
op|'('
name|'self'
op|'.'
name|'context'
op|','
op|'**'
name|'fields'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertRaises'
op|'('
name|'exception'
op|'.'
name|'FlavorExists'
op|','
name|'flavor'
op|'.'
name|'create'
op|')'
newline|'\n'
nl|'\n'
dedent|''
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.db.flavor_access_add'"
op|')'
newline|'\n'
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.db.flavor_access_remove'"
op|')'
newline|'\n'
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.db.flavor_extra_specs_delete'"
op|')'
newline|'\n'
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.db.flavor_extra_specs_update_or_create'"
op|')'
newline|'\n'
DECL|member|test_save
name|'def'
name|'test_save'
op|'('
name|'self'
op|','
name|'mock_update'
op|','
name|'mock_delete'
op|','
name|'mock_remove'
op|','
name|'mock_add'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'ctxt'
op|'='
name|'self'
op|'.'
name|'context'
op|'.'
name|'elevated'
op|'('
op|')'
newline|'\n'
name|'extra_specs'
op|'='
op|'{'
string|"'key1'"
op|':'
string|"'value1'"
op|','
string|"'key2'"
op|':'
string|"'value2'"
op|'}'
newline|'\n'
name|'projects'
op|'='
op|'['
string|"'project-1'"
op|','
string|"'project-2'"
op|']'
newline|'\n'
name|'flavor'
op|'='
name|'flavor_obj'
op|'.'
name|'Flavor'
op|'('
name|'context'
op|'='
name|'ctxt'
op|','
name|'flavorid'
op|'='
string|"'foo'"
op|','
name|'id'
op|'='
number|'123'
op|','
nl|'\n'
name|'extra_specs'
op|'='
name|'extra_specs'
op|','
name|'projects'
op|'='
name|'projects'
op|')'
newline|'\n'
name|'flavor'
op|'.'
name|'obj_reset_changes'
op|'('
op|')'
newline|'\n'
nl|'\n'
comment|'# Test deleting an extra_specs key and project'
nl|'\n'
name|'del'
name|'flavor'
op|'.'
name|'extra_specs'
op|'['
string|"'key1'"
op|']'
newline|'\n'
name|'del'
name|'flavor'
op|'.'
name|'projects'
op|'['
op|'-'
number|'1'
op|']'
newline|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
name|'set'
op|'('
op|'['
string|"'extra_specs'"
op|','
string|"'projects'"
op|']'
op|')'
op|','
nl|'\n'
name|'flavor'
op|'.'
name|'obj_what_changed'
op|'('
op|')'
op|')'
newline|'\n'
name|'flavor'
op|'.'
name|'save'
op|'('
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
op|'{'
string|"'key2'"
op|':'
string|"'value2'"
op|'}'
op|','
name|'flavor'
op|'.'
name|'extra_specs'
op|')'
newline|'\n'
name|'mock_delete'
op|'.'
name|'assert_called_once_with'
op|'('
name|'ctxt'
op|','
string|"'foo'"
op|','
string|"'key1'"
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
op|'['
string|"'project-1'"
op|']'
op|','
name|'flavor'
op|'.'
name|'projects'
op|')'
newline|'\n'
name|'mock_remove'
op|'.'
name|'assert_called_once_with'
op|'('
name|'ctxt'
op|','
string|"'foo'"
op|','
string|"'project-2'"
op|')'
newline|'\n'
nl|'\n'
comment|'# Test updating an extra_specs key value'
nl|'\n'
name|'flavor'
op|'.'
name|'extra_specs'
op|'['
string|"'key2'"
op|']'
op|'='
string|"'foobar'"
newline|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
name|'set'
op|'('
op|'['
string|"'extra_specs'"
op|']'
op|')'
op|','
name|'flavor'
op|'.'
name|'obj_what_changed'
op|'('
op|')'
op|')'
newline|'\n'
name|'flavor'
op|'.'
name|'save'
op|'('
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
op|'{'
string|"'key2'"
op|':'
string|"'foobar'"
op|'}'
op|','
name|'flavor'
op|'.'
name|'extra_specs'
op|')'
newline|'\n'
name|'mock_update'
op|'.'
name|'assert_called_with'
op|'('
name|'ctxt'
op|','
string|"'foo'"
op|','
op|'{'
string|"'key2'"
op|':'
string|"'foobar'"
op|'}'
op|')'
newline|'\n'
nl|'\n'
comment|'# Test adding an extra_specs and project'
nl|'\n'
name|'flavor'
op|'.'
name|'extra_specs'
op|'['
string|"'key3'"
op|']'
op|'='
string|"'value3'"
newline|'\n'
name|'flavor'
op|'.'
name|'projects'
op|'.'
name|'append'
op|'('
string|"'project-3'"
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
name|'set'
op|'('
op|'['
string|"'extra_specs'"
op|','
string|"'projects'"
op|']'
op|')'
op|','
nl|'\n'
name|'flavor'
op|'.'
name|'obj_what_changed'
op|'('
op|')'
op|')'
newline|'\n'
name|'flavor'
op|'.'
name|'save'
op|'('
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
op|'{'
string|"'key2'"
op|':'
string|"'foobar'"
op|','
string|"'key3'"
op|':'
string|"'value3'"
op|'}'
op|','
nl|'\n'
name|'flavor'
op|'.'
name|'extra_specs'
op|')'
newline|'\n'
name|'mock_update'
op|'.'
name|'assert_called_with'
op|'('
name|'ctxt'
op|','
string|"'foo'"
op|','
op|'{'
string|"'key2'"
op|':'
string|"'foobar'"
op|','
nl|'\n'
string|"'key3'"
op|':'
string|"'value3'"
op|'}'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
op|'['
string|"'project-1'"
op|','
string|"'project-3'"
op|']'
op|','
name|'flavor'
op|'.'
name|'projects'
op|')'
newline|'\n'
name|'mock_add'
op|'.'
name|'assert_called_once_with'
op|'('
name|'ctxt'
op|','
string|"'foo'"
op|','
string|"'project-3'"
op|')'
newline|'\n'
nl|'\n'
dedent|''
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.Flavor._flavor_add_project'"
op|')'
newline|'\n'
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.Flavor._flavor_del_project'"
op|')'
newline|'\n'
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.Flavor._flavor_extra_specs_del'"
op|')'
newline|'\n'
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.Flavor._flavor_extra_specs_add'"
op|')'
newline|'\n'
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.Flavor.in_api'"
op|','
name|'new'
op|'='
name|'True'
op|')'
newline|'\n'
DECL|member|test_save_api
name|'def'
name|'test_save_api'
op|'('
name|'self'
op|','
name|'mock_update'
op|','
name|'mock_delete'
op|','
name|'mock_remove'
op|','
name|'mock_add'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'extra_specs'
op|'='
op|'{'
string|"'key1'"
op|':'
string|"'value1'"
op|','
string|"'key2'"
op|':'
string|"'value2'"
op|'}'
newline|'\n'
name|'projects'
op|'='
op|'['
string|"'project-1'"
op|','
string|"'project-2'"
op|']'
newline|'\n'
name|'flavor'
op|'='
name|'flavor_obj'
op|'.'
name|'Flavor'
op|'('
name|'context'
op|'='
name|'self'
op|'.'
name|'context'
op|','
name|'flavorid'
op|'='
string|"'foo'"
op|','
nl|'\n'
name|'id'
op|'='
number|'123'
op|','
name|'extra_specs'
op|'='
name|'extra_specs'
op|','
nl|'\n'
name|'projects'
op|'='
name|'projects'
op|')'
newline|'\n'
name|'flavor'
op|'.'
name|'obj_reset_changes'
op|'('
op|')'
newline|'\n'
nl|'\n'
comment|'# Test deleting an extra_specs key and project'
nl|'\n'
name|'del'
name|'flavor'
op|'.'
name|'extra_specs'
op|'['
string|"'key1'"
op|']'
newline|'\n'
name|'del'
name|'flavor'
op|'.'
name|'projects'
op|'['
op|'-'
number|'1'
op|']'
newline|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
name|'set'
op|'('
op|'['
string|"'extra_specs'"
op|','
string|"'projects'"
op|']'
op|')'
op|','
nl|'\n'
name|'flavor'
op|'.'
name|'obj_what_changed'
op|'('
op|')'
op|')'
newline|'\n'
name|'flavor'
op|'.'
name|'save'
op|'('
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
op|'{'
string|"'key2'"
op|':'
string|"'value2'"
op|'}'
op|','
name|'flavor'
op|'.'
name|'extra_specs'
op|')'
newline|'\n'
name|'mock_delete'
op|'.'
name|'assert_called_once_with'
op|'('
name|'self'
op|'.'
name|'context'
op|','
number|'123'
op|','
string|"'key1'"
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
op|'['
string|"'project-1'"
op|']'
op|','
name|'flavor'
op|'.'
name|'projects'
op|')'
newline|'\n'
name|'mock_remove'
op|'.'
name|'assert_called_once_with'
op|'('
name|'self'
op|'.'
name|'context'
op|','
number|'123'
op|','
string|"'project-2'"
op|')'
newline|'\n'
nl|'\n'
comment|'# Test updating an extra_specs key value'
nl|'\n'
name|'flavor'
op|'.'
name|'extra_specs'
op|'['
string|"'key2'"
op|']'
op|'='
string|"'foobar'"
newline|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
name|'set'
op|'('
op|'['
string|"'extra_specs'"
op|']'
op|')'
op|','
name|'flavor'
op|'.'
name|'obj_what_changed'
op|'('
op|')'
op|')'
newline|'\n'
name|'flavor'
op|'.'
name|'save'
op|'('
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
op|'{'
string|"'key2'"
op|':'
string|"'foobar'"
op|'}'
op|','
name|'flavor'
op|'.'
name|'extra_specs'
op|')'
newline|'\n'
name|'mock_update'
op|'.'
name|'assert_called_with'
op|'('
name|'self'
op|'.'
name|'context'
op|','
number|'123'
op|','
op|'{'
string|"'key2'"
op|':'
string|"'foobar'"
op|'}'
op|')'
newline|'\n'
nl|'\n'
comment|'# Test adding an extra_specs and project'
nl|'\n'
name|'flavor'
op|'.'
name|'extra_specs'
op|'['
string|"'key3'"
op|']'
op|'='
string|"'value3'"
newline|'\n'
name|'flavor'
op|'.'
name|'projects'
op|'.'
name|'append'
op|'('
string|"'project-3'"
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
name|'set'
op|'('
op|'['
string|"'extra_specs'"
op|','
string|"'projects'"
op|']'
op|')'
op|','
nl|'\n'
name|'flavor'
op|'.'
name|'obj_what_changed'
op|'('
op|')'
op|')'
newline|'\n'
name|'flavor'
op|'.'
name|'save'
op|'('
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
op|'{'
string|"'key2'"
op|':'
string|"'foobar'"
op|','
string|"'key3'"
op|':'
string|"'value3'"
op|'}'
op|','
nl|'\n'
name|'flavor'
op|'.'
name|'extra_specs'
op|')'
newline|'\n'
name|'mock_update'
op|'.'
name|'assert_called_with'
op|'('
name|'self'
op|'.'
name|'context'
op|','
number|'123'
op|','
op|'{'
string|"'key2'"
op|':'
string|"'foobar'"
op|','
nl|'\n'
string|"'key3'"
op|':'
string|"'value3'"
op|'}'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
op|'['
string|"'project-1'"
op|','
string|"'project-3'"
op|']'
op|','
name|'flavor'
op|'.'
name|'projects'
op|')'
newline|'\n'
name|'mock_add'
op|'.'
name|'assert_called_once_with'
op|'('
name|'self'
op|'.'
name|'context'
op|','
number|'123'
op|','
string|"'project-3'"
op|')'
newline|'\n'
nl|'\n'
dedent|''
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.Flavor._flavor_create'"
op|')'
newline|'\n'
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.Flavor._flavor_extra_specs_del'"
op|')'
newline|'\n'
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.Flavor._flavor_extra_specs_add'"
op|')'
newline|'\n'
DECL|member|test_save_deleted_extra_specs
name|'def'
name|'test_save_deleted_extra_specs'
op|'('
name|'self'
op|','
name|'mock_add'
op|','
name|'mock_delete'
op|','
nl|'\n'
name|'mock_create'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'mock_create'
op|'.'
name|'return_value'
op|'='
name|'dict'
op|'('
name|'fake_flavor'
op|','
nl|'\n'
name|'extra_specs'
op|'='
op|'{'
string|"'key1'"
op|':'
string|"'value1'"
op|'}'
op|')'
newline|'\n'
name|'flavor'
op|'='
name|'flavor_obj'
op|'.'
name|'Flavor'
op|'('
name|'context'
op|'='
name|'self'
op|'.'
name|'context'
op|')'
newline|'\n'
name|'flavor'
op|'.'
name|'flavorid'
op|'='
string|"'test'"
newline|'\n'
name|'flavor'
op|'.'
name|'extra_specs'
op|'='
op|'{'
string|"'key1'"
op|':'
string|"'value1'"
op|'}'
newline|'\n'
name|'flavor'
op|'.'
name|'create'
op|'('
op|')'
newline|'\n'
name|'flavor'
op|'.'
name|'extra_specs'
op|'='
op|'{'
op|'}'
newline|'\n'
name|'flavor'
op|'.'
name|'save'
op|'('
op|')'
newline|'\n'
name|'mock_delete'
op|'.'
name|'assert_called_once_with'
op|'('
name|'self'
op|'.'
name|'context'
op|','
name|'flavor'
op|'.'
name|'id'
op|','
string|"'key1'"
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertFalse'
op|'('
name|'mock_add'
op|'.'
name|'called'
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_save_invalid_fields
dedent|''
name|'def'
name|'test_save_invalid_fields'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'flavor'
op|'='
name|'flavor_obj'
op|'.'
name|'Flavor'
op|'('
name|'id'
op|'='
number|'123'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertRaises'
op|'('
name|'exception'
op|'.'
name|'ObjectActionError'
op|','
name|'flavor'
op|'.'
name|'save'
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_destroy
dedent|''
name|'def'
name|'test_destroy'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'flavor'
op|'='
name|'flavor_obj'
op|'.'
name|'Flavor'
op|'('
name|'context'
op|'='
name|'self'
op|'.'
name|'context'
op|','
name|'name'
op|'='
string|"'foo'"
op|')'
newline|'\n'
name|'with'
name|'mock'
op|'.'
name|'patch'
op|'.'
name|'object'
op|'('
name|'db'
op|','
string|"'flavor_destroy'"
op|')'
name|'as'
name|'destroy'
op|':'
newline|'\n'
indent|'            '
name|'flavor'
op|'.'
name|'destroy'
op|'('
op|')'
newline|'\n'
name|'destroy'
op|'.'
name|'assert_called_once_with'
op|'('
name|'self'
op|'.'
name|'context'
op|','
name|'flavor'
op|'.'
name|'name'
op|')'
newline|'\n'
nl|'\n'
dedent|''
dedent|''
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.Flavor._flavor_destroy'"
op|')'
newline|'\n'
DECL|member|test_destroy_api_by_id
name|'def'
name|'test_destroy_api_by_id'
op|'('
name|'self'
op|','
name|'mock_destroy'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'flavor'
op|'='
name|'flavor_obj'
op|'.'
name|'Flavor'
op|'('
name|'context'
op|'='
name|'self'
op|'.'
name|'context'
op|','
name|'id'
op|'='
number|'123'
op|')'
newline|'\n'
name|'flavor'
op|'.'
name|'destroy'
op|'('
op|')'
newline|'\n'
name|'mock_destroy'
op|'.'
name|'assert_called_once_with'
op|'('
name|'self'
op|'.'
name|'context'
op|','
name|'flavor_id'
op|'='
name|'flavor'
op|'.'
name|'id'
op|')'
newline|'\n'
nl|'\n'
dedent|''
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.Flavor._flavor_destroy'"
op|')'
newline|'\n'
DECL|member|test_destroy_api_by_name
name|'def'
name|'test_destroy_api_by_name'
op|'('
name|'self'
op|','
name|'mock_destroy'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'flavor'
op|'='
name|'flavor_obj'
op|'.'
name|'Flavor'
op|'('
name|'context'
op|'='
name|'self'
op|'.'
name|'context'
op|','
name|'name'
op|'='
string|"'foo'"
op|')'
newline|'\n'
name|'flavor'
op|'.'
name|'destroy'
op|'('
op|')'
newline|'\n'
name|'mock_destroy'
op|'.'
name|'assert_called_once_with'
op|'('
name|'self'
op|'.'
name|'context'
op|','
name|'name'
op|'='
name|'flavor'
op|'.'
name|'name'
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_load_projects
dedent|''
name|'def'
name|'test_load_projects'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'flavor'
op|'='
name|'flavor_obj'
op|'.'
name|'Flavor'
op|'('
name|'context'
op|'='
name|'self'
op|'.'
name|'context'
op|','
name|'flavorid'
op|'='
string|"'foo'"
op|')'
newline|'\n'
name|'with'
name|'mock'
op|'.'
name|'patch'
op|'.'
name|'object'
op|'('
name|'db'
op|','
string|"'flavor_access_get_by_flavor_id'"
op|')'
name|'as'
name|'get'
op|':'
newline|'\n'
indent|'            '
name|'get'
op|'.'
name|'return_value'
op|'='
op|'['
op|'{'
string|"'project_id'"
op|':'
string|"'project-1'"
op|'}'
op|']'
newline|'\n'
name|'projects'
op|'='
name|'flavor'
op|'.'
name|'projects'
newline|'\n'
nl|'\n'
dedent|''
name|'self'
op|'.'
name|'assertEqual'
op|'('
op|'['
string|"'project-1'"
op|']'
op|','
name|'projects'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertNotIn'
op|'('
string|"'projects'"
op|','
name|'flavor'
op|'.'
name|'obj_what_changed'
op|'('
op|')'
op|')'
newline|'\n'
nl|'\n'
dedent|''
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.Flavor._get_projects_from_db'"
op|')'
newline|'\n'
DECL|member|test_load_projects_from_api
name|'def'
name|'test_load_projects_from_api'
op|'('
name|'self'
op|','
name|'mock_get_projects'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'mock_get_projects'
op|'.'
name|'return_value'
op|'='
op|'['
string|"'a'"
op|','
string|"'b'"
op|']'
newline|'\n'
name|'flavor'
op|'='
name|'objects'
op|'.'
name|'Flavor'
op|'('
name|'context'
op|'='
name|'self'
op|'.'
name|'context'
op|','
name|'flavorid'
op|'='
string|"'m1.foo'"
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
op|'['
string|"'a'"
op|','
string|"'b'"
op|']'
op|','
name|'flavor'
op|'.'
name|'projects'
op|')'
newline|'\n'
name|'mock_get_projects'
op|'.'
name|'assert_called_once_with'
op|'('
name|'self'
op|'.'
name|'context'
op|','
string|"'m1.foo'"
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_from_db_loads_projects
dedent|''
name|'def'
name|'test_from_db_loads_projects'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'fake'
op|'='
name|'dict'
op|'('
name|'fake_api_flavor'
op|','
name|'projects'
op|'='
op|'['
op|'{'
string|"'project_id'"
op|':'
string|"'foo'"
op|'}'
op|']'
op|')'
newline|'\n'
name|'obj'
op|'='
name|'objects'
op|'.'
name|'Flavor'
op|'.'
name|'_from_db_object'
op|'('
name|'self'
op|'.'
name|'context'
op|','
name|'objects'
op|'.'
name|'Flavor'
op|'('
op|')'
op|','
nl|'\n'
name|'fake'
op|','
name|'expected_attrs'
op|'='
op|'['
string|"'projects'"
op|']'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertIn'
op|'('
string|"'projects'"
op|','
name|'obj'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
op|'['
string|"'foo'"
op|']'
op|','
name|'obj'
op|'.'
name|'projects'
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_load_anything_else
dedent|''
name|'def'
name|'test_load_anything_else'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'flavor'
op|'='
name|'flavor_obj'
op|'.'
name|'Flavor'
op|'('
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertRaises'
op|'('
name|'exception'
op|'.'
name|'ObjectActionError'
op|','
nl|'\n'
name|'getattr'
op|','
name|'flavor'
op|','
string|"'name'"
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_in_api
dedent|''
name|'def'
name|'test_in_api'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'flavor'
op|'='
name|'objects'
op|'.'
name|'Flavor'
op|'('
name|'context'
op|'='
name|'self'
op|'.'
name|'context'
op|','
name|'id'
op|'='
number|'123'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertFalse'
op|'('
name|'flavor'
op|'.'
name|'_in_api'
op|')'
newline|'\n'
nl|'\n'
comment|'# First call, flavor not found, should be false'
nl|'\n'
name|'with'
name|'mock'
op|'.'
name|'patch'
op|'.'
name|'object'
op|'('
name|'flavor'
op|','
string|"'_flavor_get_from_db'"
op|')'
name|'as'
name|'mock_g'
op|':'
newline|'\n'
indent|'            '
name|'mock_g'
op|'.'
name|'side_effect'
op|'='
name|'exception'
op|'.'
name|'FlavorNotFound'
op|'('
name|'flavor_id'
op|'='
string|"'123'"
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertFalse'
op|'('
name|'flavor'
op|'.'
name|'in_api'
op|')'
newline|'\n'
name|'mock_g'
op|'.'
name|'assert_called_once_with'
op|'('
name|'self'
op|'.'
name|'context'
op|','
number|'123'
op|')'
newline|'\n'
nl|'\n'
comment|'# Second call, still not found, make sure we checked again'
nl|'\n'
dedent|''
name|'with'
name|'mock'
op|'.'
name|'patch'
op|'.'
name|'object'
op|'('
name|'flavor'
op|','
string|"'_flavor_get_from_db'"
op|')'
name|'as'
name|'mock_g'
op|':'
newline|'\n'
indent|'            '
name|'mock_g'
op|'.'
name|'side_effect'
op|'='
name|'exception'
op|'.'
name|'FlavorNotFound'
op|'('
name|'flavor_id'
op|'='
string|"'123'"
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertFalse'
op|'('
name|'flavor'
op|'.'
name|'in_api'
op|')'
newline|'\n'
name|'mock_g'
op|'.'
name|'assert_called_once_with'
op|'('
name|'self'
op|'.'
name|'context'
op|','
number|'123'
op|')'
newline|'\n'
nl|'\n'
comment|'# Third, flavor found, should be true'
nl|'\n'
dedent|''
name|'with'
name|'mock'
op|'.'
name|'patch'
op|'.'
name|'object'
op|'('
name|'flavor'
op|','
string|"'_flavor_get_from_db'"
op|')'
name|'as'
name|'mock_g'
op|':'
newline|'\n'
indent|'            '
name|'self'
op|'.'
name|'assertTrue'
op|'('
name|'flavor'
op|'.'
name|'in_api'
op|')'
newline|'\n'
name|'mock_g'
op|'.'
name|'assert_called_once_with'
op|'('
name|'self'
op|'.'
name|'context'
op|','
number|'123'
op|')'
newline|'\n'
nl|'\n'
comment|"# Fourth, flavor was already found, shouldn't check again, still true"
nl|'\n'
dedent|''
name|'with'
name|'mock'
op|'.'
name|'patch'
op|'.'
name|'object'
op|'('
name|'flavor'
op|','
string|"'_flavor_get_from_db'"
op|')'
name|'as'
name|'mock_g'
op|':'
newline|'\n'
indent|'            '
name|'self'
op|'.'
name|'assertTrue'
op|'('
name|'flavor'
op|'.'
name|'in_api'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertFalse'
op|'('
name|'mock_g'
op|'.'
name|'called'
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_in_api_fixes_id
dedent|''
dedent|''
name|'def'
name|'test_in_api_fixes_id'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'flavor'
op|'='
name|'objects'
op|'.'
name|'Flavor'
op|'('
name|'context'
op|'='
name|'self'
op|'.'
name|'context'
op|','
name|'flavorid'
op|'='
string|"'foo'"
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertNotIn'
op|'('
string|"'id'"
op|','
name|'flavor'
op|')'
newline|'\n'
name|'with'
name|'mock'
op|'.'
name|'patch'
op|'.'
name|'object'
op|'('
nl|'\n'
name|'flavor'
op|','
string|"'_flavor_get_by_flavor_id_from_db'"
op|')'
name|'as'
name|'m'
op|':'
newline|'\n'
indent|'            '
name|'m'
op|'.'
name|'return_value'
op|'='
op|'{'
string|"'id'"
op|':'
number|'123'
op|'}'
newline|'\n'
name|'flavor'
op|'.'
name|'in_api'
newline|'\n'
name|'self'
op|'.'
name|'assertIn'
op|'('
string|"'id'"
op|','
name|'flavor'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
number|'123'
op|','
name|'flavor'
op|'.'
name|'id'
op|')'
newline|'\n'
nl|'\n'
nl|'\n'
DECL|class|TestFlavor
dedent|''
dedent|''
dedent|''
name|'class'
name|'TestFlavor'
op|'('
name|'test_objects'
op|'.'
name|'_LocalTest'
op|','
name|'_TestFlavor'
op|')'
op|':'
newline|'\n'
comment|'# NOTE(danms): Run this test local-only because we would otherwise'
nl|'\n'
comment|'# have to do a bunch of change-resetting to handle the way we do'
nl|'\n'
comment|'# our change tracking for special attributes like projects. There is'
nl|'\n'
comment|'# nothing remotely-concerning (see what I did there?) so this is fine.'
nl|'\n'
DECL|member|test_projects_in_db
indent|'    '
name|'def'
name|'test_projects_in_db'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'db_flavor'
op|'='
name|'self'
op|'.'
name|'_create_api_flavor'
op|'('
name|'self'
op|'.'
name|'context'
op|')'
newline|'\n'
name|'flavor'
op|'='
name|'objects'
op|'.'
name|'Flavor'
op|'.'
name|'get_by_id'
op|'('
name|'self'
op|'.'
name|'context'
op|','
name|'db_flavor'
op|'['
string|"'id'"
op|']'
op|')'
newline|'\n'
name|'flavor'
op|'.'
name|'add_access'
op|'('
string|"'project1'"
op|')'
newline|'\n'
name|'flavor'
op|'.'
name|'add_access'
op|'('
string|"'project2'"
op|')'
newline|'\n'
name|'flavor'
op|'.'
name|'add_access'
op|'('
string|"'project3'"
op|')'
newline|'\n'
name|'flavor'
op|'.'
name|'remove_access'
op|'('
string|"'project2'"
op|')'
newline|'\n'
name|'flavor'
op|'='
name|'flavor'
op|'.'
name|'get_by_id'
op|'('
name|'self'
op|'.'
name|'context'
op|','
name|'db_flavor'
op|'['
string|"'id'"
op|']'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
op|'['
string|"'project1'"
op|','
string|"'project3'"
op|']'
op|','
name|'flavor'
op|'.'
name|'projects'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertRaises'
op|'('
name|'exception'
op|'.'
name|'FlavorAccessExists'
op|','
nl|'\n'
name|'flavor'
op|'.'
name|'add_access'
op|','
string|"'project1'"
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertRaises'
op|'('
name|'exception'
op|'.'
name|'FlavorAccessNotFound'
op|','
nl|'\n'
name|'flavor'
op|'.'
name|'remove_access'
op|','
string|"'project2'"
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_extra_specs_in_db
dedent|''
name|'def'
name|'test_extra_specs_in_db'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'db_flavor'
op|'='
name|'self'
op|'.'
name|'_create_api_flavor'
op|'('
name|'self'
op|'.'
name|'context'
op|')'
newline|'\n'
name|'flavor'
op|'='
name|'objects'
op|'.'
name|'Flavor'
op|'.'
name|'get_by_id'
op|'('
name|'self'
op|'.'
name|'context'
op|','
name|'db_flavor'
op|'['
string|"'id'"
op|']'
op|')'
newline|'\n'
name|'flavor'
op|'.'
name|'extra_specs'
op|'['
string|"'marty'"
op|']'
op|'='
string|"'mcfly'"
newline|'\n'
name|'del'
name|'flavor'
op|'.'
name|'extra_specs'
op|'['
string|"'foo'"
op|']'
newline|'\n'
name|'flavor'
op|'.'
name|'save'
op|'('
op|')'
newline|'\n'
name|'flavor'
op|'='
name|'objects'
op|'.'
name|'Flavor'
op|'.'
name|'get_by_id'
op|'('
name|'self'
op|'.'
name|'context'
op|','
name|'db_flavor'
op|'['
string|"'id'"
op|']'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
op|'{'
string|"'marty'"
op|':'
string|"'mcfly'"
op|'}'
op|','
name|'flavor'
op|'.'
name|'extra_specs'
op|')'
newline|'\n'
nl|'\n'
nl|'\n'
DECL|class|TestFlavorRemote
dedent|''
dedent|''
name|'class'
name|'TestFlavorRemote'
op|'('
name|'test_objects'
op|'.'
name|'_RemoteTest'
op|','
name|'_TestFlavor'
op|')'
op|':'
newline|'\n'
indent|'    '
name|'pass'
newline|'\n'
nl|'\n'
nl|'\n'
DECL|class|_TestFlavorList
dedent|''
name|'class'
name|'_TestFlavorList'
op|'('
name|'object'
op|')'
op|':'
newline|'\n'
indent|'    '
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.db.flavor_get_all'"
op|')'
newline|'\n'
DECL|member|test_get_all_from_db
name|'def'
name|'test_get_all_from_db'
op|'('
name|'self'
op|','
name|'mock_get'
op|')'
op|':'
newline|'\n'
comment|'# Get a list of the actual flavors in the API DB'
nl|'\n'
indent|'        '
name|'api_flavors'
op|'='
name|'flavor_obj'
op|'.'
name|'_flavor_get_all_from_db'
op|'('
name|'self'
op|'.'
name|'context'
op|','
nl|'\n'
name|'False'
op|','
name|'None'
op|','
nl|'\n'
string|"'flavorid'"
op|','
string|"'asc'"
op|','
nl|'\n'
name|'None'
op|','
name|'None'
op|')'
newline|'\n'
comment|'# Return a fake flavor from the main DB query'
nl|'\n'
name|'db_flavors'
op|'='
op|'['
name|'fake_flavor'
op|']'
newline|'\n'
name|'mock_get'
op|'.'
name|'return_value'
op|'='
name|'db_flavors'
newline|'\n'
nl|'\n'
name|'flavors'
op|'='
name|'objects'
op|'.'
name|'FlavorList'
op|'.'
name|'get_all'
op|'('
name|'self'
op|'.'
name|'context'
op|')'
newline|'\n'
comment|"# Make sure we're getting all flavors from the api and main"
nl|'\n'
comment|'# db queries'
nl|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
name|'len'
op|'('
name|'db_flavors'
op|')'
op|'+'
name|'len'
op|'('
name|'api_flavors'
op|')'
op|','
name|'len'
op|'('
name|'flavors'
op|')'
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_get_all_from_db_with_limit
dedent|''
name|'def'
name|'test_get_all_from_db_with_limit'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'flavors'
op|'='
name|'objects'
op|'.'
name|'FlavorList'
op|'.'
name|'get_all'
op|'('
name|'self'
op|'.'
name|'context'
op|','
nl|'\n'
name|'limit'
op|'='
number|'1'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
number|'1'
op|','
name|'len'
op|'('
name|'flavors'
op|')'
op|')'
newline|'\n'
nl|'\n'
dedent|''
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.db.flavor_get_all'"
op|')'
newline|'\n'
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.flavor._flavor_get_all_from_db'"
op|')'
newline|'\n'
DECL|member|test_get_all
name|'def'
name|'test_get_all'
op|'('
name|'self'
op|','
name|'mock_api_get'
op|','
name|'mock_main_get'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'_fake_api_flavor'
op|'='
name|'dict'
op|'('
name|'fake_api_flavor'
op|','
nl|'\n'
name|'id'
op|'='
number|'2'
op|','
name|'name'
op|'='
string|"'m1.bar'"
op|','
name|'flavorid'
op|'='
string|"'m1.bar'"
op|')'
newline|'\n'
nl|'\n'
name|'mock_api_get'
op|'.'
name|'return_value'
op|'='
op|'['
name|'_fake_api_flavor'
op|']'
newline|'\n'
name|'mock_main_get'
op|'.'
name|'return_value'
op|'='
op|'['
name|'fake_flavor'
op|']'
newline|'\n'
name|'filters'
op|'='
op|'{'
string|"'min_memory_mb'"
op|':'
number|'4096'
op|'}'
newline|'\n'
name|'flavors'
op|'='
name|'flavor_obj'
op|'.'
name|'FlavorList'
op|'.'
name|'get_all'
op|'('
name|'self'
op|'.'
name|'context'
op|','
nl|'\n'
name|'inactive'
op|'='
name|'False'
op|','
nl|'\n'
name|'filters'
op|'='
name|'filters'
op|','
nl|'\n'
name|'sort_key'
op|'='
string|"'id'"
op|','
nl|'\n'
name|'sort_dir'
op|'='
string|"'asc'"
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
number|'2'
op|','
name|'len'
op|'('
name|'flavors'
op|')'
op|')'
newline|'\n'
name|'_TestFlavor'
op|'.'
name|'_compare'
op|'('
name|'self'
op|','
name|'_fake_api_flavor'
op|','
name|'flavors'
op|'['
number|'0'
op|']'
op|')'
newline|'\n'
name|'_TestFlavor'
op|'.'
name|'_compare'
op|'('
name|'self'
op|','
name|'fake_flavor'
op|','
name|'flavors'
op|'['
number|'1'
op|']'
op|')'
newline|'\n'
name|'mock_api_get'
op|'.'
name|'assert_called_once_with'
op|'('
name|'self'
op|'.'
name|'context'
op|','
name|'inactive'
op|'='
name|'False'
op|','
nl|'\n'
name|'filters'
op|'='
name|'filters'
op|','
name|'sort_key'
op|'='
string|"'id'"
op|','
nl|'\n'
name|'sort_dir'
op|'='
string|"'asc'"
op|','
name|'limit'
op|'='
name|'None'
op|','
nl|'\n'
name|'marker'
op|'='
name|'None'
op|')'
newline|'\n'
nl|'\n'
name|'mock_main_get'
op|'.'
name|'assert_called_once_with'
op|'('
name|'self'
op|'.'
name|'context'
op|','
name|'inactive'
op|'='
name|'False'
op|','
nl|'\n'
name|'filters'
op|'='
name|'filters'
op|','
name|'sort_key'
op|'='
string|"'id'"
op|','
nl|'\n'
name|'sort_dir'
op|'='
string|"'asc'"
op|','
name|'limit'
op|'='
name|'None'
op|','
nl|'\n'
name|'marker'
op|'='
name|'None'
op|')'
newline|'\n'
nl|'\n'
dedent|''
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.db.flavor_get_all'"
op|')'
newline|'\n'
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.flavor._flavor_get_all_from_db'"
op|')'
newline|'\n'
DECL|member|test_get_all_limit_applied_to_api
name|'def'
name|'test_get_all_limit_applied_to_api'
op|'('
name|'self'
op|','
name|'mock_api_get'
op|','
name|'mock_main_get'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'_fake_api_flavor'
op|'='
name|'dict'
op|'('
name|'fake_api_flavor'
op|','
nl|'\n'
name|'id'
op|'='
number|'2'
op|','
name|'name'
op|'='
string|"'m1.bar'"
op|','
name|'flavorid'
op|'='
string|"'m1.bar'"
op|')'
newline|'\n'
nl|'\n'
name|'mock_api_get'
op|'.'
name|'return_value'
op|'='
op|'['
name|'_fake_api_flavor'
op|']'
newline|'\n'
name|'mock_main_get'
op|'.'
name|'return_value'
op|'='
op|'['
name|'fake_flavor'
op|']'
newline|'\n'
name|'filters'
op|'='
op|'{'
string|"'min_memory_mb'"
op|':'
number|'4096'
op|'}'
newline|'\n'
name|'flavors'
op|'='
name|'flavor_obj'
op|'.'
name|'FlavorList'
op|'.'
name|'get_all'
op|'('
name|'self'
op|'.'
name|'context'
op|','
nl|'\n'
name|'inactive'
op|'='
name|'False'
op|','
nl|'\n'
name|'filters'
op|'='
name|'filters'
op|','
nl|'\n'
name|'limit'
op|'='
number|'2'
op|','
nl|'\n'
name|'sort_key'
op|'='
string|"'id'"
op|','
nl|'\n'
name|'sort_dir'
op|'='
string|"'asc'"
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
number|'2'
op|','
name|'len'
op|'('
name|'flavors'
op|')'
op|')'
newline|'\n'
name|'_TestFlavor'
op|'.'
name|'_compare'
op|'('
name|'self'
op|','
name|'_fake_api_flavor'
op|','
name|'flavors'
op|'['
number|'0'
op|']'
op|')'
newline|'\n'
name|'_TestFlavor'
op|'.'
name|'_compare'
op|'('
name|'self'
op|','
name|'fake_flavor'
op|','
name|'flavors'
op|'['
number|'1'
op|']'
op|')'
newline|'\n'
name|'mock_api_get'
op|'.'
name|'assert_called_once_with'
op|'('
name|'self'
op|'.'
name|'context'
op|','
name|'inactive'
op|'='
name|'False'
op|','
nl|'\n'
name|'filters'
op|'='
name|'filters'
op|','
name|'sort_key'
op|'='
string|"'id'"
op|','
nl|'\n'
name|'sort_dir'
op|'='
string|"'asc'"
op|','
name|'limit'
op|'='
number|'2'
op|','
nl|'\n'
name|'marker'
op|'='
name|'None'
op|')'
newline|'\n'
nl|'\n'
name|'mock_main_get'
op|'.'
name|'assert_called_once_with'
op|'('
name|'self'
op|'.'
name|'context'
op|','
name|'inactive'
op|'='
name|'False'
op|','
nl|'\n'
name|'filters'
op|'='
name|'filters'
op|','
name|'sort_key'
op|'='
string|"'id'"
op|','
nl|'\n'
name|'sort_dir'
op|'='
string|"'asc'"
op|','
name|'limit'
op|'='
number|'1'
op|','
nl|'\n'
name|'marker'
op|'='
name|'None'
op|')'
newline|'\n'
nl|'\n'
dedent|''
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.db.flavor_get_all'"
op|')'
newline|'\n'
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.flavor._flavor_get_all_from_db'"
op|')'
newline|'\n'
DECL|member|test_get_all_limit_no_main_call
name|'def'
name|'test_get_all_limit_no_main_call'
op|'('
name|'self'
op|','
name|'mock_api_get'
op|','
name|'mock_main_get'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'_fake_api_flavor'
op|'='
name|'dict'
op|'('
name|'fake_api_flavor'
op|','
nl|'\n'
name|'id'
op|'='
number|'2'
op|','
name|'name'
op|'='
string|"'m1.bar'"
op|','
name|'flavorid'
op|'='
string|"'m1.bar'"
op|')'
newline|'\n'
nl|'\n'
name|'mock_api_get'
op|'.'
name|'return_value'
op|'='
op|'['
name|'_fake_api_flavor'
op|']'
newline|'\n'
name|'mock_main_get'
op|'.'
name|'return_value'
op|'='
op|'['
name|'fake_flavor'
op|']'
newline|'\n'
name|'filters'
op|'='
op|'{'
string|"'min_memory_mb'"
op|':'
number|'4096'
op|'}'
newline|'\n'
name|'flavors'
op|'='
name|'flavor_obj'
op|'.'
name|'FlavorList'
op|'.'
name|'get_all'
op|'('
name|'self'
op|'.'
name|'context'
op|','
nl|'\n'
name|'inactive'
op|'='
name|'False'
op|','
nl|'\n'
name|'filters'
op|'='
name|'filters'
op|','
nl|'\n'
name|'limit'
op|'='
number|'1'
op|','
nl|'\n'
name|'sort_key'
op|'='
string|"'id'"
op|','
nl|'\n'
name|'sort_dir'
op|'='
string|"'asc'"
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
number|'1'
op|','
name|'len'
op|'('
name|'flavors'
op|')'
op|')'
newline|'\n'
name|'_TestFlavor'
op|'.'
name|'_compare'
op|'('
name|'self'
op|','
name|'_fake_api_flavor'
op|','
name|'flavors'
op|'['
number|'0'
op|']'
op|')'
newline|'\n'
name|'mock_api_get'
op|'.'
name|'assert_called_once_with'
op|'('
name|'self'
op|'.'
name|'context'
op|','
name|'inactive'
op|'='
name|'False'
op|','
nl|'\n'
name|'filters'
op|'='
name|'filters'
op|','
name|'sort_key'
op|'='
string|"'id'"
op|','
nl|'\n'
name|'sort_dir'
op|'='
string|"'asc'"
op|','
name|'limit'
op|'='
number|'1'
op|','
nl|'\n'
name|'marker'
op|'='
name|'None'
op|')'
newline|'\n'
nl|'\n'
name|'self'
op|'.'
name|'assertFalse'
op|'('
name|'mock_main_get'
op|'.'
name|'called'
op|')'
newline|'\n'
nl|'\n'
dedent|''
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.db.flavor_get_all'"
op|')'
newline|'\n'
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.Flavor._flavor_get_query_from_db'"
op|')'
newline|'\n'
DECL|member|test_get_no_marker_in_api
name|'def'
name|'test_get_no_marker_in_api'
op|'('
name|'self'
op|','
name|'mock_api_get'
op|','
name|'mock_main_get'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'mock_api_get'
op|'.'
name|'filter_by'
op|'.'
name|'return_value'
op|'.'
name|'first'
op|'.'
name|'return_value'
op|'='
name|'None'
newline|'\n'
name|'mock_main_get'
op|'.'
name|'return_value'
op|'='
op|'['
op|']'
newline|'\n'
name|'flavor_obj'
op|'.'
name|'FlavorList'
op|'.'
name|'get_all'
op|'('
name|'self'
op|'.'
name|'context'
op|','
nl|'\n'
name|'inactive'
op|'='
name|'False'
op|','
nl|'\n'
name|'filters'
op|'='
name|'None'
op|','
nl|'\n'
name|'limit'
op|'='
number|'1'
op|','
nl|'\n'
name|'marker'
op|'='
string|"'foo'"
op|','
nl|'\n'
name|'sort_key'
op|'='
string|"'id'"
op|','
nl|'\n'
name|'sort_dir'
op|'='
string|"'asc'"
op|')'
newline|'\n'
name|'mock_main_get'
op|'.'
name|'assert_called_once_with'
op|'('
name|'self'
op|'.'
name|'context'
op|','
name|'inactive'
op|'='
name|'False'
op|','
nl|'\n'
name|'filters'
op|'='
name|'None'
op|','
name|'sort_key'
op|'='
string|"'id'"
op|','
nl|'\n'
name|'sort_dir'
op|'='
string|"'asc'"
op|','
name|'limit'
op|'='
number|'1'
op|','
nl|'\n'
name|'marker'
op|'='
name|'None'
op|')'
newline|'\n'
nl|'\n'
nl|'\n'
DECL|class|TestFlavorList
dedent|''
dedent|''
name|'class'
name|'TestFlavorList'
op|'('
name|'test_objects'
op|'.'
name|'_LocalTest'
op|','
name|'_TestFlavorList'
op|')'
op|':'
newline|'\n'
indent|'    '
name|'pass'
newline|'\n'
nl|'\n'
nl|'\n'
DECL|class|TestFlavorListRemote
dedent|''
name|'class'
name|'TestFlavorListRemote'
op|'('
name|'test_objects'
op|'.'
name|'_RemoteTest'
op|','
name|'_TestFlavorList'
op|')'
op|':'
newline|'\n'
indent|'    '
name|'pass'
newline|'\n'
dedent|''
endmarker|''
end_unit

begin_unit
comment|'#    Copyright 2013 Red Hat, Inc.'
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|'datetime'
newline|'\n'
nl|'\n'
name|'import'
name|'mock'
newline|'\n'
name|'from'
name|'oslo_db'
name|'import'
name|'exception'
name|'as'
name|'db_exc'
newline|'\n'
nl|'\n'
name|'from'
name|'nova'
name|'import'
name|'db'
newline|'\n'
name|'from'
name|'nova'
op|'.'
name|'db'
op|'.'
name|'sqlalchemy'
name|'import'
name|'api'
name|'as'
name|'db_api'
newline|'\n'
name|'from'
name|'nova'
op|'.'
name|'db'
op|'.'
name|'sqlalchemy'
name|'import'
name|'api_models'
newline|'\n'
name|'from'
name|'nova'
name|'import'
name|'exception'
newline|'\n'
name|'from'
name|'nova'
name|'import'
name|'objects'
newline|'\n'
name|'from'
name|'nova'
op|'.'
name|'objects'
name|'import'
name|'flavor'
name|'as'
name|'flavor_obj'
newline|'\n'
name|'from'
name|'nova'
op|'.'
name|'tests'
op|'.'
name|'unit'
op|'.'
name|'objects'
name|'import'
name|'test_objects'
newline|'\n'
nl|'\n'
nl|'\n'
DECL|variable|fake_flavor
name|'fake_flavor'
op|'='
op|'{'
nl|'\n'
string|"'created_at'"
op|':'
name|'None'
op|','
nl|'\n'
string|"'updated_at'"
op|':'
name|'None'
op|','
nl|'\n'
string|"'deleted_at'"
op|':'
name|'None'
op|','
nl|'\n'
string|"'deleted'"
op|':'
number|'0'
op|','
nl|'\n'
string|"'id'"
op|':'
number|'1'
op|','
nl|'\n'
string|"'name'"
op|':'
string|"'m1.foo'"
op|','
nl|'\n'
string|"'memory_mb'"
op|':'
number|'1024'
op|','
nl|'\n'
string|"'vcpus'"
op|':'
number|'4'
op|','
nl|'\n'
string|"'root_gb'"
op|':'
number|'20'
op|','
nl|'\n'
string|"'ephemeral_gb'"
op|':'
number|'0'
op|','
nl|'\n'
string|"'flavorid'"
op|':'
string|"'m1.foo'"
op|','
nl|'\n'
string|"'swap'"
op|':'
number|'0'
op|','
nl|'\n'
string|"'rxtx_factor'"
op|':'
number|'1.0'
op|','
nl|'\n'
string|"'vcpu_weight'"
op|':'
number|'1'
op|','
nl|'\n'
string|"'disabled'"
op|':'
name|'False'
op|','
nl|'\n'
string|"'is_public'"
op|':'
name|'True'
op|','
nl|'\n'
string|"'extra_specs'"
op|':'
op|'{'
string|"'foo'"
op|':'
string|"'bar'"
op|'}'
op|','
nl|'\n'
op|'}'
newline|'\n'
nl|'\n'
nl|'\n'
DECL|variable|fake_api_flavor
name|'fake_api_flavor'
op|'='
op|'{'
nl|'\n'
string|"'created_at'"
op|':'
name|'None'
op|','
nl|'\n'
string|"'updated_at'"
op|':'
name|'None'
op|','
nl|'\n'
string|"'id'"
op|':'
number|'1'
op|','
nl|'\n'
string|"'name'"
op|':'
string|"'m1.foo'"
op|','
nl|'\n'
string|"'memory_mb'"
op|':'
number|'1024'
op|','
nl|'\n'
string|"'vcpus'"
op|':'
number|'4'
op|','
nl|'\n'
string|"'root_gb'"
op|':'
number|'20'
op|','
nl|'\n'
string|"'ephemeral_gb'"
op|':'
number|'0'
op|','
nl|'\n'
string|"'flavorid'"
op|':'
string|"'m1.foo'"
op|','
nl|'\n'
string|"'swap'"
op|':'
number|'0'
op|','
nl|'\n'
string|"'rxtx_factor'"
op|':'
number|'1.0'
op|','
nl|'\n'
string|"'vcpu_weight'"
op|':'
number|'1'
op|','
nl|'\n'
string|"'disabled'"
op|':'
name|'False'
op|','
nl|'\n'
string|"'is_public'"
op|':'
name|'True'
op|','
nl|'\n'
string|"'extra_specs'"
op|':'
op|'{'
string|"'foo'"
op|':'
string|"'bar'"
op|'}'
op|','
nl|'\n'
op|'}'
newline|'\n'
nl|'\n'
nl|'\n'
DECL|class|_TestFlavor
name|'class'
name|'_TestFlavor'
op|'('
name|'object'
op|')'
op|':'
newline|'\n'
indent|'    '
op|'@'
name|'staticmethod'
newline|'\n'
DECL|member|_compare
name|'def'
name|'_compare'
op|'('
name|'test'
op|','
name|'db'
op|','
name|'obj'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'for'
name|'field'
op|','
name|'value'
name|'in'
name|'db'
op|'.'
name|'items'
op|'('
op|')'
op|':'
newline|'\n'
comment|'# NOTE(danms): The datetimes on SQLA models are tz-unaware,'
nl|'\n'
comment|"# but the object has tz-aware datetimes. If we're comparing"
nl|'\n'
comment|'# a model to an object (as opposed to a fake dict), just'
nl|'\n'
comment|'# ignore the datetimes in the comparison.'
nl|'\n'
indent|'            '
name|'if'
op|'('
name|'isinstance'
op|'('
name|'db'
op|','
name|'api_models'
op|'.'
name|'API_BASE'
op|')'
name|'and'
nl|'\n'
name|'isinstance'
op|'('
name|'value'
op|','
name|'datetime'
op|'.'
name|'datetime'
op|')'
op|')'
op|':'
newline|'\n'
indent|'                '
name|'continue'
newline|'\n'
dedent|''
name|'test'
op|'.'
name|'assertEqual'
op|'('
name|'db'
op|'['
name|'field'
op|']'
op|','
name|'obj'
op|'['
name|'field'
op|']'
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_get_by_id
dedent|''
dedent|''
name|'def'
name|'test_get_by_id'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'with'
name|'mock'
op|'.'
name|'patch'
op|'.'
name|'object'
op|'('
name|'db'
op|','
string|"'flavor_get'"
op|')'
name|'as'
name|'get'
op|':'
newline|'\n'
indent|'            '
name|'get'
op|'.'
name|'return_value'
op|'='
name|'fake_flavor'
newline|'\n'
name|'flavor'
op|'='
name|'flavor_obj'
op|'.'
name|'Flavor'
op|'.'
name|'get_by_id'
op|'('
name|'self'
op|'.'
name|'context'
op|','
number|'100'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'_compare'
op|'('
name|'self'
op|','
name|'fake_flavor'
op|','
name|'flavor'
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_get_by_name
dedent|''
dedent|''
name|'def'
name|'test_get_by_name'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'with'
name|'mock'
op|'.'
name|'patch'
op|'.'
name|'object'
op|'('
name|'db'
op|','
string|"'flavor_get_by_name'"
op|')'
name|'as'
name|'get_by_name'
op|':'
newline|'\n'
indent|'            '
name|'get_by_name'
op|'.'
name|'return_value'
op|'='
name|'fake_flavor'
newline|'\n'
name|'flavor'
op|'='
name|'flavor_obj'
op|'.'
name|'Flavor'
op|'.'
name|'get_by_name'
op|'('
name|'self'
op|'.'
name|'context'
op|','
string|"'m1.legacy'"
op|')'
newline|'\n'
name|'self'
op|'.'
name|'_compare'
op|'('
name|'self'
op|','
name|'fake_flavor'
op|','
name|'flavor'
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_get_by_flavor_id
dedent|''
dedent|''
name|'def'
name|'test_get_by_flavor_id'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'with'
name|'mock'
op|'.'
name|'patch'
op|'.'
name|'object'
op|'('
name|'db'
op|','
string|"'flavor_get_by_flavor_id'"
op|')'
name|'as'
name|'get_by_id'
op|':'
newline|'\n'
indent|'            '
name|'get_by_id'
op|'.'
name|'return_value'
op|'='
name|'fake_flavor'
newline|'\n'
name|'flavor'
op|'='
name|'flavor_obj'
op|'.'
name|'Flavor'
op|'.'
name|'get_by_flavor_id'
op|'('
name|'self'
op|'.'
name|'context'
op|','
nl|'\n'
string|"'m1.legacy'"
op|')'
newline|'\n'
name|'self'
op|'.'
name|'_compare'
op|'('
name|'self'
op|','
name|'fake_flavor'
op|','
name|'flavor'
op|')'
newline|'\n'
nl|'\n'
dedent|''
dedent|''
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.Flavor._flavor_get_from_db'"
op|')'
newline|'\n'
DECL|member|test_api_get_by_id_from_api
name|'def'
name|'test_api_get_by_id_from_api'
op|'('
name|'self'
op|','
name|'mock_get'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'mock_get'
op|'.'
name|'return_value'
op|'='
name|'fake_api_flavor'
newline|'\n'
name|'flavor'
op|'='
name|'flavor_obj'
op|'.'
name|'Flavor'
op|'.'
name|'get_by_id'
op|'('
name|'self'
op|'.'
name|'context'
op|','
number|'1'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'_compare'
op|'('
name|'self'
op|','
name|'fake_api_flavor'
op|','
name|'flavor'
op|')'
newline|'\n'
name|'mock_get'
op|'.'
name|'assert_called_once_with'
op|'('
name|'self'
op|'.'
name|'context'
op|','
number|'1'
op|')'
newline|'\n'
nl|'\n'
dedent|''
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.Flavor._flavor_get_by_name_from_db'"
op|')'
newline|'\n'
DECL|member|test_get_by_name_from_api
name|'def'
name|'test_get_by_name_from_api'
op|'('
name|'self'
op|','
name|'mock_get'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'mock_get'
op|'.'
name|'return_value'
op|'='
name|'fake_api_flavor'
newline|'\n'
name|'flavor'
op|'='
name|'flavor_obj'
op|'.'
name|'Flavor'
op|'.'
name|'get_by_name'
op|'('
name|'self'
op|'.'
name|'context'
op|','
string|"'m1.foo'"
op|')'
newline|'\n'
name|'self'
op|'.'
name|'_compare'
op|'('
name|'self'
op|','
name|'fake_api_flavor'
op|','
name|'flavor'
op|')'
newline|'\n'
name|'mock_get'
op|'.'
name|'assert_called_once_with'
op|'('
name|'self'
op|'.'
name|'context'
op|','
string|"'m1.foo'"
op|')'
newline|'\n'
nl|'\n'
dedent|''
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.Flavor._flavor_get_by_flavor_id_from_db'"
op|')'
newline|'\n'
DECL|member|test_get_by_flavor_id_from_api
name|'def'
name|'test_get_by_flavor_id_from_api'
op|'('
name|'self'
op|','
name|'mock_get'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'mock_get'
op|'.'
name|'return_value'
op|'='
name|'fake_api_flavor'
newline|'\n'
name|'flavor'
op|'='
name|'flavor_obj'
op|'.'
name|'Flavor'
op|'.'
name|'get_by_flavor_id'
op|'('
name|'self'
op|'.'
name|'context'
op|','
string|"'m1.foo'"
op|')'
newline|'\n'
name|'self'
op|'.'
name|'_compare'
op|'('
name|'self'
op|','
name|'fake_api_flavor'
op|','
name|'flavor'
op|')'
newline|'\n'
name|'mock_get'
op|'.'
name|'assert_called_once_with'
op|'('
name|'self'
op|'.'
name|'context'
op|','
string|"'m1.foo'"
op|')'
newline|'\n'
nl|'\n'
dedent|''
op|'@'
name|'staticmethod'
newline|'\n'
op|'@'
name|'db_api'
op|'.'
name|'api_context_manager'
op|'.'
name|'writer'
newline|'\n'
DECL|member|_create_api_flavor
name|'def'
name|'_create_api_flavor'
op|'('
name|'context'
op|','
name|'altid'
op|'='
name|'None'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'fake_db_flavor'
op|'='
name|'dict'
op|'('
name|'fake_api_flavor'
op|')'
newline|'\n'
name|'del'
name|'fake_db_flavor'
op|'['
string|"'extra_specs'"
op|']'
newline|'\n'
name|'del'
name|'fake_db_flavor'
op|'['
string|"'id'"
op|']'
newline|'\n'
name|'flavor'
op|'='
name|'api_models'
op|'.'
name|'Flavors'
op|'('
op|')'
newline|'\n'
name|'flavor'
op|'.'
name|'update'
op|'('
name|'fake_db_flavor'
op|')'
newline|'\n'
name|'if'
name|'altid'
op|':'
newline|'\n'
indent|'            '
name|'flavor'
op|'.'
name|'update'
op|'('
op|'{'
string|"'flavorid'"
op|':'
name|'altid'
op|','
nl|'\n'
string|"'name'"
op|':'
name|'altid'
op|'}'
op|')'
newline|'\n'
dedent|''
name|'flavor'
op|'.'
name|'save'
op|'('
name|'context'
op|'.'
name|'session'
op|')'
newline|'\n'
nl|'\n'
name|'fake_db_extra_spec'
op|'='
op|'{'
string|"'flavor_id'"
op|':'
name|'flavor'
op|'['
string|"'id'"
op|']'
op|','
nl|'\n'
string|"'key'"
op|':'
string|"'foo'"
op|','
string|"'value'"
op|':'
string|"'bar'"
op|'}'
newline|'\n'
name|'flavor_es'
op|'='
name|'api_models'
op|'.'
name|'FlavorExtraSpecs'
op|'('
op|')'
newline|'\n'
name|'flavor_es'
op|'.'
name|'update'
op|'('
name|'fake_db_extra_spec'
op|')'
newline|'\n'
name|'flavor_es'
op|'.'
name|'save'
op|'('
name|'context'
op|'.'
name|'session'
op|')'
newline|'\n'
nl|'\n'
name|'return'
name|'flavor'
newline|'\n'
nl|'\n'
DECL|member|test_get_by_id_from_db
dedent|''
name|'def'
name|'test_get_by_id_from_db'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'db_flavor'
op|'='
name|'self'
op|'.'
name|'_create_api_flavor'
op|'('
name|'self'
op|'.'
name|'context'
op|')'
newline|'\n'
name|'flavor'
op|'='
name|'objects'
op|'.'
name|'Flavor'
op|'.'
name|'get_by_id'
op|'('
name|'self'
op|'.'
name|'context'
op|','
name|'db_flavor'
op|'['
string|"'id'"
op|']'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'_compare'
op|'('
name|'self'
op|','
name|'db_flavor'
op|','
name|'flavor'
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_get_by_name_from_db
dedent|''
name|'def'
name|'test_get_by_name_from_db'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'db_flavor'
op|'='
name|'self'
op|'.'
name|'_create_api_flavor'
op|'('
name|'self'
op|'.'
name|'context'
op|')'
newline|'\n'
name|'flavor'
op|'='
name|'objects'
op|'.'
name|'Flavor'
op|'.'
name|'get_by_name'
op|'('
name|'self'
op|'.'
name|'context'
op|','
name|'db_flavor'
op|'['
string|"'name'"
op|']'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'_compare'
op|'('
name|'self'
op|','
name|'db_flavor'
op|','
name|'flavor'
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_get_by_flavor_id_from_db
dedent|''
name|'def'
name|'test_get_by_flavor_id_from_db'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'db_flavor'
op|'='
name|'self'
op|'.'
name|'_create_api_flavor'
op|'('
name|'self'
op|'.'
name|'context'
op|')'
newline|'\n'
name|'flavor'
op|'='
name|'objects'
op|'.'
name|'Flavor'
op|'.'
name|'get_by_flavor_id'
op|'('
name|'self'
op|'.'
name|'context'
op|','
nl|'\n'
name|'db_flavor'
op|'['
string|"'flavorid'"
op|']'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'_compare'
op|'('
name|'self'
op|','
name|'db_flavor'
op|','
name|'flavor'
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_add_access
dedent|''
name|'def'
name|'test_add_access'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'elevated'
op|'='
name|'self'
op|'.'
name|'context'
op|'.'
name|'elevated'
op|'('
op|')'
newline|'\n'
name|'flavor'
op|'='
name|'flavor_obj'
op|'.'
name|'Flavor'
op|'('
name|'context'
op|'='
name|'elevated'
op|','
name|'id'
op|'='
number|'12345'
op|','
name|'flavorid'
op|'='
string|"'123'"
op|')'
newline|'\n'
name|'with'
name|'mock'
op|'.'
name|'patch'
op|'.'
name|'object'
op|'('
name|'db'
op|','
string|"'flavor_access_add'"
op|')'
name|'as'
name|'add'
op|':'
newline|'\n'
indent|'            '
name|'flavor'
op|'.'
name|'add_access'
op|'('
string|"'456'"
op|')'
newline|'\n'
name|'add'
op|'.'
name|'assert_called_once_with'
op|'('
name|'elevated'
op|','
string|"'123'"
op|','
string|"'456'"
op|')'
newline|'\n'
nl|'\n'
dedent|''
dedent|''
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.db.flavor_access_add'"
op|')'
newline|'\n'
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.Flavor._flavor_add_project'"
op|')'
newline|'\n'
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.Flavor.in_api'"
op|','
name|'new'
op|'='
name|'True'
op|')'
newline|'\n'
DECL|member|test_add_access_api
name|'def'
name|'test_add_access_api'
op|'('
name|'self'
op|','
name|'mock_api_add'
op|','
name|'mock_main_add'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'elevated'
op|'='
name|'self'
op|'.'
name|'context'
op|'.'
name|'elevated'
op|'('
op|')'
newline|'\n'
name|'flavor'
op|'='
name|'flavor_obj'
op|'.'
name|'Flavor'
op|'('
name|'context'
op|'='
name|'elevated'
op|','
name|'id'
op|'='
number|'12345'
op|','
name|'flavorid'
op|'='
string|"'123'"
op|')'
newline|'\n'
name|'flavor'
op|'.'
name|'add_access'
op|'('
string|"'456'"
op|')'
newline|'\n'
name|'mock_api_add'
op|'.'
name|'assert_called_once_with'
op|'('
name|'elevated'
op|','
number|'12345'
op|','
string|"'456'"
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertFalse'
op|'('
name|'mock_main_add'
op|'.'
name|'called'
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_add_access_with_dirty_projects
dedent|''
name|'def'
name|'test_add_access_with_dirty_projects'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'flavor'
op|'='
name|'flavor_obj'
op|'.'
name|'Flavor'
op|'('
name|'context'
op|'='
name|'self'
op|'.'
name|'context'
op|','
name|'projects'
op|'='
op|'['
string|"'1'"
op|']'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertRaises'
op|'('
name|'exception'
op|'.'
name|'ObjectActionError'
op|','
nl|'\n'
name|'flavor'
op|'.'
name|'add_access'
op|','
string|"'2'"
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_remove_access
dedent|''
name|'def'
name|'test_remove_access'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'elevated'
op|'='
name|'self'
op|'.'
name|'context'
op|'.'
name|'elevated'
op|'('
op|')'
newline|'\n'
name|'flavor'
op|'='
name|'flavor_obj'
op|'.'
name|'Flavor'
op|'('
name|'context'
op|'='
name|'elevated'
op|','
name|'id'
op|'='
number|'12345'
op|','
name|'flavorid'
op|'='
string|"'123'"
op|')'
newline|'\n'
name|'with'
name|'mock'
op|'.'
name|'patch'
op|'.'
name|'object'
op|'('
name|'db'
op|','
string|"'flavor_access_remove'"
op|')'
name|'as'
name|'remove'
op|':'
newline|'\n'
indent|'            '
name|'flavor'
op|'.'
name|'remove_access'
op|'('
string|"'456'"
op|')'
newline|'\n'
name|'remove'
op|'.'
name|'assert_called_once_with'
op|'('
name|'elevated'
op|','
string|"'123'"
op|','
string|"'456'"
op|')'
newline|'\n'
nl|'\n'
dedent|''
dedent|''
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.db.flavor_access_add'"
op|')'
newline|'\n'
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.Flavor._flavor_del_project'"
op|')'
newline|'\n'
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.Flavor.in_api'"
op|','
name|'new'
op|'='
name|'True'
op|')'
newline|'\n'
DECL|member|test_remove_access_api
name|'def'
name|'test_remove_access_api'
op|'('
name|'self'
op|','
name|'mock_api_del'
op|','
name|'mock_main_del'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'elevated'
op|'='
name|'self'
op|'.'
name|'context'
op|'.'
name|'elevated'
op|'('
op|')'
newline|'\n'
name|'flavor'
op|'='
name|'flavor_obj'
op|'.'
name|'Flavor'
op|'('
name|'context'
op|'='
name|'elevated'
op|','
name|'id'
op|'='
number|'12345'
op|','
name|'flavorid'
op|'='
string|"'123'"
op|')'
newline|'\n'
name|'flavor'
op|'.'
name|'remove_access'
op|'('
string|"'456'"
op|')'
newline|'\n'
name|'mock_api_del'
op|'.'
name|'assert_called_once_with'
op|'('
name|'elevated'
op|','
number|'12345'
op|','
string|"'456'"
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertFalse'
op|'('
name|'mock_main_del'
op|'.'
name|'called'
op|')'
newline|'\n'
nl|'\n'
dedent|''
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.Flavor._flavor_create'"
op|')'
newline|'\n'
DECL|member|test_create
name|'def'
name|'test_create'
op|'('
name|'self'
op|','
name|'mock_create'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'mock_create'
op|'.'
name|'return_value'
op|'='
name|'fake_api_flavor'
newline|'\n'
nl|'\n'
name|'flavor'
op|'='
name|'flavor_obj'
op|'.'
name|'Flavor'
op|'('
name|'context'
op|'='
name|'self'
op|'.'
name|'context'
op|')'
newline|'\n'
name|'flavor'
op|'.'
name|'name'
op|'='
string|"'m1.foo'"
newline|'\n'
name|'flavor'
op|'.'
name|'extra_specs'
op|'='
name|'fake_flavor'
op|'['
string|"'extra_specs'"
op|']'
newline|'\n'
name|'flavor'
op|'.'
name|'create'
op|'('
op|')'
newline|'\n'
nl|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
name|'self'
op|'.'
name|'context'
op|','
name|'flavor'
op|'.'
name|'_context'
op|')'
newline|'\n'
comment|'# NOTE(danms): Orphan this to avoid lazy-loads'
nl|'\n'
name|'flavor'
op|'.'
name|'_context'
op|'='
name|'None'
newline|'\n'
name|'self'
op|'.'
name|'_compare'
op|'('
name|'self'
op|','
name|'fake_flavor'
op|','
name|'flavor'
op|')'
newline|'\n'
nl|'\n'
dedent|''
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.Flavor._flavor_create'"
op|')'
newline|'\n'
DECL|member|test_create_with_projects
name|'def'
name|'test_create_with_projects'
op|'('
name|'self'
op|','
name|'mock_create'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'context'
op|'='
name|'self'
op|'.'
name|'context'
op|'.'
name|'elevated'
op|'('
op|')'
newline|'\n'
name|'flavor'
op|'='
name|'flavor_obj'
op|'.'
name|'Flavor'
op|'('
name|'context'
op|'='
name|'context'
op|')'
newline|'\n'
name|'flavor'
op|'.'
name|'name'
op|'='
string|"'m1.foo'"
newline|'\n'
name|'flavor'
op|'.'
name|'extra_specs'
op|'='
name|'fake_flavor'
op|'['
string|"'extra_specs'"
op|']'
newline|'\n'
name|'flavor'
op|'.'
name|'projects'
op|'='
op|'['
string|"'project-1'"
op|','
string|"'project-2'"
op|']'
newline|'\n'
nl|'\n'
name|'db_flavor'
op|'='
name|'dict'
op|'('
name|'fake_flavor'
op|','
nl|'\n'
name|'projects'
op|'='
op|'['
op|'{'
string|"'project_id'"
op|':'
name|'pid'
op|'}'
nl|'\n'
name|'for'
name|'pid'
name|'in'
name|'flavor'
op|'.'
name|'projects'
op|']'
op|')'
newline|'\n'
name|'mock_create'
op|'.'
name|'return_value'
op|'='
name|'db_flavor'
newline|'\n'
name|'flavor'
op|'.'
name|'create'
op|'('
op|')'
newline|'\n'
nl|'\n'
name|'mock_create'
op|'.'
name|'assert_called_once_with'
op|'('
nl|'\n'
name|'context'
op|','
op|'{'
string|"'name'"
op|':'
string|"'m1.foo'"
op|','
nl|'\n'
string|"'extra_specs'"
op|':'
name|'fake_flavor'
op|'['
string|"'extra_specs'"
op|']'
op|','
nl|'\n'
string|"'projects'"
op|':'
op|'['
string|"'project-1'"
op|','
string|"'project-2'"
op|']'
op|'}'
op|')'
newline|'\n'
nl|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
name|'context'
op|','
name|'flavor'
op|'.'
name|'_context'
op|')'
newline|'\n'
comment|'# NOTE(danms): Orphan this to avoid lazy-loads'
nl|'\n'
name|'flavor'
op|'.'
name|'_context'
op|'='
name|'None'
newline|'\n'
name|'self'
op|'.'
name|'_compare'
op|'('
name|'self'
op|','
name|'fake_flavor'
op|','
name|'flavor'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
op|'['
string|"'project-1'"
op|','
string|"'project-2'"
op|']'
op|','
name|'flavor'
op|'.'
name|'projects'
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_create_with_id
dedent|''
name|'def'
name|'test_create_with_id'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'flavor'
op|'='
name|'flavor_obj'
op|'.'
name|'Flavor'
op|'('
name|'context'
op|'='
name|'self'
op|'.'
name|'context'
op|','
name|'id'
op|'='
number|'123'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertRaises'
op|'('
name|'exception'
op|'.'
name|'ObjectActionError'
op|','
name|'flavor'
op|'.'
name|'create'
op|')'
newline|'\n'
nl|'\n'
dedent|''
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.db.sqlalchemy.api_models.Flavors'"
op|')'
newline|'\n'
DECL|member|test_create_duplicate
name|'def'
name|'test_create_duplicate'
op|'('
name|'self'
op|','
name|'mock_flavors'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'mock_flavors'
op|'.'
name|'return_value'
op|'.'
name|'save'
op|'.'
name|'side_effect'
op|'='
name|'db_exc'
op|'.'
name|'DBDuplicateEntry'
newline|'\n'
name|'fields'
op|'='
name|'dict'
op|'('
name|'fake_api_flavor'
op|')'
newline|'\n'
name|'del'
name|'fields'
op|'['
string|"'id'"
op|']'
newline|'\n'
name|'flavor'
op|'='
name|'objects'
op|'.'
name|'Flavor'
op|'('
name|'self'
op|'.'
name|'context'
op|','
op|'**'
name|'fields'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertRaises'
op|'('
name|'exception'
op|'.'
name|'FlavorExists'
op|','
name|'flavor'
op|'.'
name|'create'
op|')'
newline|'\n'
nl|'\n'
dedent|''
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.db.flavor_access_add'"
op|')'
newline|'\n'
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.db.flavor_access_remove'"
op|')'
newline|'\n'
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.db.flavor_extra_specs_delete'"
op|')'
newline|'\n'
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.db.flavor_extra_specs_update_or_create'"
op|')'
newline|'\n'
DECL|member|test_save
name|'def'
name|'test_save'
op|'('
name|'self'
op|','
name|'mock_update'
op|','
name|'mock_delete'
op|','
name|'mock_remove'
op|','
name|'mock_add'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'ctxt'
op|'='
name|'self'
op|'.'
name|'context'
op|'.'
name|'elevated'
op|'('
op|')'
newline|'\n'
name|'extra_specs'
op|'='
op|'{'
string|"'key1'"
op|':'
string|"'value1'"
op|','
string|"'key2'"
op|':'
string|"'value2'"
op|'}'
newline|'\n'
name|'projects'
op|'='
op|'['
string|"'project-1'"
op|','
string|"'project-2'"
op|']'
newline|'\n'
name|'flavor'
op|'='
name|'flavor_obj'
op|'.'
name|'Flavor'
op|'('
name|'context'
op|'='
name|'ctxt'
op|','
name|'flavorid'
op|'='
string|"'foo'"
op|','
name|'id'
op|'='
number|'123'
op|','
nl|'\n'
name|'extra_specs'
op|'='
name|'extra_specs'
op|','
name|'projects'
op|'='
name|'projects'
op|')'
newline|'\n'
name|'flavor'
op|'.'
name|'obj_reset_changes'
op|'('
op|')'
newline|'\n'
nl|'\n'
comment|'# Test deleting an extra_specs key and project'
nl|'\n'
name|'del'
name|'flavor'
op|'.'
name|'extra_specs'
op|'['
string|"'key1'"
op|']'
newline|'\n'
name|'del'
name|'flavor'
op|'.'
name|'projects'
op|'['
op|'-'
number|'1'
op|']'
newline|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
name|'set'
op|'('
op|'['
string|"'extra_specs'"
op|','
string|"'projects'"
op|']'
op|')'
op|','
nl|'\n'
name|'flavor'
op|'.'
name|'obj_what_changed'
op|'('
op|')'
op|')'
newline|'\n'
name|'flavor'
op|'.'
name|'save'
op|'('
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
op|'{'
string|"'key2'"
op|':'
string|"'value2'"
op|'}'
op|','
name|'flavor'
op|'.'
name|'extra_specs'
op|')'
newline|'\n'
name|'mock_delete'
op|'.'
name|'assert_called_once_with'
op|'('
name|'ctxt'
op|','
string|"'foo'"
op|','
string|"'key1'"
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
op|'['
string|"'project-1'"
op|']'
op|','
name|'flavor'
op|'.'
name|'projects'
op|')'
newline|'\n'
name|'mock_remove'
op|'.'
name|'assert_called_once_with'
op|'('
name|'ctxt'
op|','
string|"'foo'"
op|','
string|"'project-2'"
op|')'
newline|'\n'
nl|'\n'
comment|'# Test updating an extra_specs key value'
nl|'\n'
name|'flavor'
op|'.'
name|'extra_specs'
op|'['
string|"'key2'"
op|']'
op|'='
string|"'foobar'"
newline|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
name|'set'
op|'('
op|'['
string|"'extra_specs'"
op|']'
op|')'
op|','
name|'flavor'
op|'.'
name|'obj_what_changed'
op|'('
op|')'
op|')'
newline|'\n'
name|'flavor'
op|'.'
name|'save'
op|'('
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
op|'{'
string|"'key2'"
op|':'
string|"'foobar'"
op|'}'
op|','
name|'flavor'
op|'.'
name|'extra_specs'
op|')'
newline|'\n'
name|'mock_update'
op|'.'
name|'assert_called_with'
op|'('
name|'ctxt'
op|','
string|"'foo'"
op|','
op|'{'
string|"'key2'"
op|':'
string|"'foobar'"
op|'}'
op|')'
newline|'\n'
nl|'\n'
comment|'# Test adding an extra_specs and project'
nl|'\n'
name|'flavor'
op|'.'
name|'extra_specs'
op|'['
string|"'key3'"
op|']'
op|'='
string|"'value3'"
newline|'\n'
name|'flavor'
op|'.'
name|'projects'
op|'.'
name|'append'
op|'('
string|"'project-3'"
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
name|'set'
op|'('
op|'['
string|"'extra_specs'"
op|','
string|"'projects'"
op|']'
op|')'
op|','
nl|'\n'
name|'flavor'
op|'.'
name|'obj_what_changed'
op|'('
op|')'
op|')'
newline|'\n'
name|'flavor'
op|'.'
name|'save'
op|'('
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
op|'{'
string|"'key2'"
op|':'
string|"'foobar'"
op|','
string|"'key3'"
op|':'
string|"'value3'"
op|'}'
op|','
nl|'\n'
name|'flavor'
op|'.'
name|'extra_specs'
op|')'
newline|'\n'
name|'mock_update'
op|'.'
name|'assert_called_with'
op|'('
name|'ctxt'
op|','
string|"'foo'"
op|','
op|'{'
string|"'key2'"
op|':'
string|"'foobar'"
op|','
nl|'\n'
string|"'key3'"
op|':'
string|"'value3'"
op|'}'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
op|'['
string|"'project-1'"
op|','
string|"'project-3'"
op|']'
op|','
name|'flavor'
op|'.'
name|'projects'
op|')'
newline|'\n'
name|'mock_add'
op|'.'
name|'assert_called_once_with'
op|'('
name|'ctxt'
op|','
string|"'foo'"
op|','
string|"'project-3'"
op|')'
newline|'\n'
nl|'\n'
dedent|''
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.Flavor._flavor_add_project'"
op|')'
newline|'\n'
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.Flavor._flavor_del_project'"
op|')'
newline|'\n'
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.Flavor._flavor_extra_specs_del'"
op|')'
newline|'\n'
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.Flavor._flavor_extra_specs_add'"
op|')'
newline|'\n'
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.Flavor.in_api'"
op|','
name|'new'
op|'='
name|'True'
op|')'
newline|'\n'
DECL|member|test_save_api
name|'def'
name|'test_save_api'
op|'('
name|'self'
op|','
name|'mock_update'
op|','
name|'mock_delete'
op|','
name|'mock_remove'
op|','
name|'mock_add'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'extra_specs'
op|'='
op|'{'
string|"'key1'"
op|':'
string|"'value1'"
op|','
string|"'key2'"
op|':'
string|"'value2'"
op|'}'
newline|'\n'
name|'projects'
op|'='
op|'['
string|"'project-1'"
op|','
string|"'project-2'"
op|']'
newline|'\n'
name|'flavor'
op|'='
name|'flavor_obj'
op|'.'
name|'Flavor'
op|'('
name|'context'
op|'='
name|'self'
op|'.'
name|'context'
op|','
name|'flavorid'
op|'='
string|"'foo'"
op|','
nl|'\n'
name|'id'
op|'='
number|'123'
op|','
name|'extra_specs'
op|'='
name|'extra_specs'
op|','
nl|'\n'
name|'projects'
op|'='
name|'projects'
op|')'
newline|'\n'
name|'flavor'
op|'.'
name|'obj_reset_changes'
op|'('
op|')'
newline|'\n'
nl|'\n'
comment|'# Test deleting an extra_specs key and project'
nl|'\n'
name|'del'
name|'flavor'
op|'.'
name|'extra_specs'
op|'['
string|"'key1'"
op|']'
newline|'\n'
name|'del'
name|'flavor'
op|'.'
name|'projects'
op|'['
op|'-'
number|'1'
op|']'
newline|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
name|'set'
op|'('
op|'['
string|"'extra_specs'"
op|','
string|"'projects'"
op|']'
op|')'
op|','
nl|'\n'
name|'flavor'
op|'.'
name|'obj_what_changed'
op|'('
op|')'
op|')'
newline|'\n'
name|'flavor'
op|'.'
name|'save'
op|'('
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
op|'{'
string|"'key2'"
op|':'
string|"'value2'"
op|'}'
op|','
name|'flavor'
op|'.'
name|'extra_specs'
op|')'
newline|'\n'
name|'mock_delete'
op|'.'
name|'assert_called_once_with'
op|'('
name|'self'
op|'.'
name|'context'
op|','
number|'123'
op|','
string|"'key1'"
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
op|'['
string|"'project-1'"
op|']'
op|','
name|'flavor'
op|'.'
name|'projects'
op|')'
newline|'\n'
name|'mock_remove'
op|'.'
name|'assert_called_once_with'
op|'('
name|'self'
op|'.'
name|'context'
op|','
number|'123'
op|','
string|"'project-2'"
op|')'
newline|'\n'
nl|'\n'
comment|'# Test updating an extra_specs key value'
nl|'\n'
name|'flavor'
op|'.'
name|'extra_specs'
op|'['
string|"'key2'"
op|']'
op|'='
string|"'foobar'"
newline|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
name|'set'
op|'('
op|'['
string|"'extra_specs'"
op|']'
op|')'
op|','
name|'flavor'
op|'.'
name|'obj_what_changed'
op|'('
op|')'
op|')'
newline|'\n'
name|'flavor'
op|'.'
name|'save'
op|'('
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
op|'{'
string|"'key2'"
op|':'
string|"'foobar'"
op|'}'
op|','
name|'flavor'
op|'.'
name|'extra_specs'
op|')'
newline|'\n'
name|'mock_update'
op|'.'
name|'assert_called_with'
op|'('
name|'self'
op|'.'
name|'context'
op|','
number|'123'
op|','
op|'{'
string|"'key2'"
op|':'
string|"'foobar'"
op|'}'
op|')'
newline|'\n'
nl|'\n'
comment|'# Test adding an extra_specs and project'
nl|'\n'
name|'flavor'
op|'.'
name|'extra_specs'
op|'['
string|"'key3'"
op|']'
op|'='
string|"'value3'"
newline|'\n'
name|'flavor'
op|'.'
name|'projects'
op|'.'
name|'append'
op|'('
string|"'project-3'"
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
name|'set'
op|'('
op|'['
string|"'extra_specs'"
op|','
string|"'projects'"
op|']'
op|')'
op|','
nl|'\n'
name|'flavor'
op|'.'
name|'obj_what_changed'
op|'('
op|')'
op|')'
newline|'\n'
name|'flavor'
op|'.'
name|'save'
op|'('
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
op|'{'
string|"'key2'"
op|':'
string|"'foobar'"
op|','
string|"'key3'"
op|':'
string|"'value3'"
op|'}'
op|','
nl|'\n'
name|'flavor'
op|'.'
name|'extra_specs'
op|')'
newline|'\n'
name|'mock_update'
op|'.'
name|'assert_called_with'
op|'('
name|'self'
op|'.'
name|'context'
op|','
number|'123'
op|','
op|'{'
string|"'key2'"
op|':'
string|"'foobar'"
op|','
nl|'\n'
string|"'key3'"
op|':'
string|"'value3'"
op|'}'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
op|'['
string|"'project-1'"
op|','
string|"'project-3'"
op|']'
op|','
name|'flavor'
op|'.'
name|'projects'
op|')'
newline|'\n'
name|'mock_add'
op|'.'
name|'assert_called_once_with'
op|'('
name|'self'
op|'.'
name|'context'
op|','
number|'123'
op|','
string|"'project-3'"
op|')'
newline|'\n'
nl|'\n'
dedent|''
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.Flavor._flavor_create'"
op|')'
newline|'\n'
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.Flavor._flavor_extra_specs_del'"
op|')'
newline|'\n'
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.Flavor._flavor_extra_specs_add'"
op|')'
newline|'\n'
DECL|member|test_save_deleted_extra_specs
name|'def'
name|'test_save_deleted_extra_specs'
op|'('
name|'self'
op|','
name|'mock_add'
op|','
name|'mock_delete'
op|','
nl|'\n'
name|'mock_create'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'mock_create'
op|'.'
name|'return_value'
op|'='
name|'dict'
op|'('
name|'fake_flavor'
op|','
nl|'\n'
name|'extra_specs'
op|'='
op|'{'
string|"'key1'"
op|':'
string|"'value1'"
op|'}'
op|')'
newline|'\n'
name|'flavor'
op|'='
name|'flavor_obj'
op|'.'
name|'Flavor'
op|'('
name|'context'
op|'='
name|'self'
op|'.'
name|'context'
op|')'
newline|'\n'
name|'flavor'
op|'.'
name|'flavorid'
op|'='
string|"'test'"
newline|'\n'
name|'flavor'
op|'.'
name|'extra_specs'
op|'='
op|'{'
string|"'key1'"
op|':'
string|"'value1'"
op|'}'
newline|'\n'
name|'flavor'
op|'.'
name|'create'
op|'('
op|')'
newline|'\n'
name|'flavor'
op|'.'
name|'extra_specs'
op|'='
op|'{'
op|'}'
newline|'\n'
name|'flavor'
op|'.'
name|'save'
op|'('
op|')'
newline|'\n'
name|'mock_delete'
op|'.'
name|'assert_called_once_with'
op|'('
name|'self'
op|'.'
name|'context'
op|','
name|'flavor'
op|'.'
name|'id'
op|','
string|"'key1'"
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertFalse'
op|'('
name|'mock_add'
op|'.'
name|'called'
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_save_invalid_fields
dedent|''
name|'def'
name|'test_save_invalid_fields'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'flavor'
op|'='
name|'flavor_obj'
op|'.'
name|'Flavor'
op|'('
name|'id'
op|'='
number|'123'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertRaises'
op|'('
name|'exception'
op|'.'
name|'ObjectActionError'
op|','
name|'flavor'
op|'.'
name|'save'
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_destroy
dedent|''
name|'def'
name|'test_destroy'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'flavor'
op|'='
name|'flavor_obj'
op|'.'
name|'Flavor'
op|'('
name|'context'
op|'='
name|'self'
op|'.'
name|'context'
op|','
name|'name'
op|'='
string|"'foo'"
op|')'
newline|'\n'
name|'with'
name|'mock'
op|'.'
name|'patch'
op|'.'
name|'object'
op|'('
name|'db'
op|','
string|"'flavor_destroy'"
op|')'
name|'as'
name|'destroy'
op|':'
newline|'\n'
indent|'            '
name|'flavor'
op|'.'
name|'destroy'
op|'('
op|')'
newline|'\n'
name|'destroy'
op|'.'
name|'assert_called_once_with'
op|'('
name|'self'
op|'.'
name|'context'
op|','
name|'flavor'
op|'.'
name|'name'
op|')'
newline|'\n'
nl|'\n'
dedent|''
dedent|''
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.Flavor._flavor_destroy'"
op|')'
newline|'\n'
DECL|member|test_destroy_api_by_id
name|'def'
name|'test_destroy_api_by_id'
op|'('
name|'self'
op|','
name|'mock_destroy'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'flavor'
op|'='
name|'flavor_obj'
op|'.'
name|'Flavor'
op|'('
name|'context'
op|'='
name|'self'
op|'.'
name|'context'
op|','
name|'id'
op|'='
number|'123'
op|')'
newline|'\n'
name|'flavor'
op|'.'
name|'destroy'
op|'('
op|')'
newline|'\n'
name|'mock_destroy'
op|'.'
name|'assert_called_once_with'
op|'('
name|'self'
op|'.'
name|'context'
op|','
name|'flavor_id'
op|'='
name|'flavor'
op|'.'
name|'id'
op|')'
newline|'\n'
nl|'\n'
dedent|''
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.Flavor._flavor_destroy'"
op|')'
newline|'\n'
DECL|member|test_destroy_api_by_name
name|'def'
name|'test_destroy_api_by_name'
op|'('
name|'self'
op|','
name|'mock_destroy'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'flavor'
op|'='
name|'flavor_obj'
op|'.'
name|'Flavor'
op|'('
name|'context'
op|'='
name|'self'
op|'.'
name|'context'
op|','
name|'name'
op|'='
string|"'foo'"
op|')'
newline|'\n'
name|'flavor'
op|'.'
name|'destroy'
op|'('
op|')'
newline|'\n'
name|'mock_destroy'
op|'.'
name|'assert_called_once_with'
op|'('
name|'self'
op|'.'
name|'context'
op|','
name|'name'
op|'='
name|'flavor'
op|'.'
name|'name'
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_load_projects
dedent|''
name|'def'
name|'test_load_projects'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'flavor'
op|'='
name|'flavor_obj'
op|'.'
name|'Flavor'
op|'('
name|'context'
op|'='
name|'self'
op|'.'
name|'context'
op|','
name|'flavorid'
op|'='
string|"'foo'"
op|')'
newline|'\n'
name|'with'
name|'mock'
op|'.'
name|'patch'
op|'.'
name|'object'
op|'('
name|'db'
op|','
string|"'flavor_access_get_by_flavor_id'"
op|')'
name|'as'
name|'get'
op|':'
newline|'\n'
indent|'            '
name|'get'
op|'.'
name|'return_value'
op|'='
op|'['
op|'{'
string|"'project_id'"
op|':'
string|"'project-1'"
op|'}'
op|']'
newline|'\n'
name|'projects'
op|'='
name|'flavor'
op|'.'
name|'projects'
newline|'\n'
nl|'\n'
dedent|''
name|'self'
op|'.'
name|'assertEqual'
op|'('
op|'['
string|"'project-1'"
op|']'
op|','
name|'projects'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertNotIn'
op|'('
string|"'projects'"
op|','
name|'flavor'
op|'.'
name|'obj_what_changed'
op|'('
op|')'
op|')'
newline|'\n'
nl|'\n'
dedent|''
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.Flavor._get_projects_from_db'"
op|')'
newline|'\n'
DECL|member|test_load_projects_from_api
name|'def'
name|'test_load_projects_from_api'
op|'('
name|'self'
op|','
name|'mock_get_projects'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'mock_get_projects'
op|'.'
name|'return_value'
op|'='
op|'['
string|"'a'"
op|','
string|"'b'"
op|']'
newline|'\n'
name|'flavor'
op|'='
name|'objects'
op|'.'
name|'Flavor'
op|'('
name|'context'
op|'='
name|'self'
op|'.'
name|'context'
op|','
name|'flavorid'
op|'='
string|"'m1.foo'"
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
op|'['
string|"'a'"
op|','
string|"'b'"
op|']'
op|','
name|'flavor'
op|'.'
name|'projects'
op|')'
newline|'\n'
name|'mock_get_projects'
op|'.'
name|'assert_called_once_with'
op|'('
name|'self'
op|'.'
name|'context'
op|','
string|"'m1.foo'"
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_from_db_loads_projects
dedent|''
name|'def'
name|'test_from_db_loads_projects'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'fake'
op|'='
name|'dict'
op|'('
name|'fake_api_flavor'
op|','
name|'projects'
op|'='
op|'['
op|'{'
string|"'project_id'"
op|':'
string|"'foo'"
op|'}'
op|']'
op|')'
newline|'\n'
name|'obj'
op|'='
name|'objects'
op|'.'
name|'Flavor'
op|'.'
name|'_from_db_object'
op|'('
name|'self'
op|'.'
name|'context'
op|','
name|'objects'
op|'.'
name|'Flavor'
op|'('
op|')'
op|','
nl|'\n'
name|'fake'
op|','
name|'expected_attrs'
op|'='
op|'['
string|"'projects'"
op|']'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertIn'
op|'('
string|"'projects'"
op|','
name|'obj'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
op|'['
string|"'foo'"
op|']'
op|','
name|'obj'
op|'.'
name|'projects'
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_load_anything_else
dedent|''
name|'def'
name|'test_load_anything_else'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'flavor'
op|'='
name|'flavor_obj'
op|'.'
name|'Flavor'
op|'('
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertRaises'
op|'('
name|'exception'
op|'.'
name|'ObjectActionError'
op|','
nl|'\n'
name|'getattr'
op|','
name|'flavor'
op|','
string|"'name'"
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_in_api
dedent|''
name|'def'
name|'test_in_api'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'flavor'
op|'='
name|'objects'
op|'.'
name|'Flavor'
op|'('
name|'context'
op|'='
name|'self'
op|'.'
name|'context'
op|','
name|'id'
op|'='
number|'123'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertFalse'
op|'('
name|'flavor'
op|'.'
name|'_in_api'
op|')'
newline|'\n'
nl|'\n'
comment|'# First call, flavor not found, should be false'
nl|'\n'
name|'with'
name|'mock'
op|'.'
name|'patch'
op|'.'
name|'object'
op|'('
name|'flavor'
op|','
string|"'_flavor_get_from_db'"
op|')'
name|'as'
name|'mock_g'
op|':'
newline|'\n'
indent|'            '
name|'mock_g'
op|'.'
name|'side_effect'
op|'='
name|'exception'
op|'.'
name|'FlavorNotFound'
op|'('
name|'flavor_id'
op|'='
string|"'123'"
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertFalse'
op|'('
name|'flavor'
op|'.'
name|'in_api'
op|')'
newline|'\n'
name|'mock_g'
op|'.'
name|'assert_called_once_with'
op|'('
name|'self'
op|'.'
name|'context'
op|','
number|'123'
op|')'
newline|'\n'
nl|'\n'
comment|'# Second call, still not found, make sure we checked again'
nl|'\n'
dedent|''
name|'with'
name|'mock'
op|'.'
name|'patch'
op|'.'
name|'object'
op|'('
name|'flavor'
op|','
string|"'_flavor_get_from_db'"
op|')'
name|'as'
name|'mock_g'
op|':'
newline|'\n'
indent|'            '
name|'mock_g'
op|'.'
name|'side_effect'
op|'='
name|'exception'
op|'.'
name|'FlavorNotFound'
op|'('
name|'flavor_id'
op|'='
string|"'123'"
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertFalse'
op|'('
name|'flavor'
op|'.'
name|'in_api'
op|')'
newline|'\n'
name|'mock_g'
op|'.'
name|'assert_called_once_with'
op|'('
name|'self'
op|'.'
name|'context'
op|','
number|'123'
op|')'
newline|'\n'
nl|'\n'
comment|'# Third, flavor found, should be true'
nl|'\n'
dedent|''
name|'with'
name|'mock'
op|'.'
name|'patch'
op|'.'
name|'object'
op|'('
name|'flavor'
op|','
string|"'_flavor_get_from_db'"
op|')'
name|'as'
name|'mock_g'
op|':'
newline|'\n'
indent|'            '
name|'self'
op|'.'
name|'assertTrue'
op|'('
name|'flavor'
op|'.'
name|'in_api'
op|')'
newline|'\n'
name|'mock_g'
op|'.'
name|'assert_called_once_with'
op|'('
name|'self'
op|'.'
name|'context'
op|','
number|'123'
op|')'
newline|'\n'
nl|'\n'
comment|"# Fourth, flavor was already found, shouldn't check again, still true"
nl|'\n'
dedent|''
name|'with'
name|'mock'
op|'.'
name|'patch'
op|'.'
name|'object'
op|'('
name|'flavor'
op|','
string|"'_flavor_get_from_db'"
op|')'
name|'as'
name|'mock_g'
op|':'
newline|'\n'
indent|'            '
name|'self'
op|'.'
name|'assertTrue'
op|'('
name|'flavor'
op|'.'
name|'in_api'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertFalse'
op|'('
name|'mock_g'
op|'.'
name|'called'
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_in_api_fixes_id
dedent|''
dedent|''
name|'def'
name|'test_in_api_fixes_id'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'flavor'
op|'='
name|'objects'
op|'.'
name|'Flavor'
op|'('
name|'context'
op|'='
name|'self'
op|'.'
name|'context'
op|','
name|'flavorid'
op|'='
string|"'foo'"
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertNotIn'
op|'('
string|"'id'"
op|','
name|'flavor'
op|')'
newline|'\n'
name|'with'
name|'mock'
op|'.'
name|'patch'
op|'.'
name|'object'
op|'('
nl|'\n'
name|'flavor'
op|','
string|"'_flavor_get_by_flavor_id_from_db'"
op|')'
name|'as'
name|'m'
op|':'
newline|'\n'
indent|'            '
name|'m'
op|'.'
name|'return_value'
op|'='
op|'{'
string|"'id'"
op|':'
number|'123'
op|'}'
newline|'\n'
name|'flavor'
op|'.'
name|'in_api'
newline|'\n'
name|'self'
op|'.'
name|'assertIn'
op|'('
string|"'id'"
op|','
name|'flavor'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
number|'123'
op|','
name|'flavor'
op|'.'
name|'id'
op|')'
newline|'\n'
nl|'\n'
nl|'\n'
DECL|class|TestFlavor
dedent|''
dedent|''
dedent|''
name|'class'
name|'TestFlavor'
op|'('
name|'test_objects'
op|'.'
name|'_LocalTest'
op|','
name|'_TestFlavor'
op|')'
op|':'
newline|'\n'
comment|'# NOTE(danms): Run this test local-only because we would otherwise'
nl|'\n'
comment|'# have to do a bunch of change-resetting to handle the way we do'
nl|'\n'
comment|'# our change tracking for special attributes like projects. There is'
nl|'\n'
comment|'# nothing remotely-concerning (see what I did there?) so this is fine.'
nl|'\n'
DECL|member|test_projects_in_db
indent|'    '
name|'def'
name|'test_projects_in_db'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'db_flavor'
op|'='
name|'self'
op|'.'
name|'_create_api_flavor'
op|'('
name|'self'
op|'.'
name|'context'
op|')'
newline|'\n'
name|'flavor'
op|'='
name|'objects'
op|'.'
name|'Flavor'
op|'.'
name|'get_by_id'
op|'('
name|'self'
op|'.'
name|'context'
op|','
name|'db_flavor'
op|'['
string|"'id'"
op|']'
op|')'
newline|'\n'
name|'flavor'
op|'.'
name|'add_access'
op|'('
string|"'project1'"
op|')'
newline|'\n'
name|'flavor'
op|'.'
name|'add_access'
op|'('
string|"'project2'"
op|')'
newline|'\n'
name|'flavor'
op|'.'
name|'add_access'
op|'('
string|"'project3'"
op|')'
newline|'\n'
name|'flavor'
op|'.'
name|'remove_access'
op|'('
string|"'project2'"
op|')'
newline|'\n'
name|'flavor'
op|'='
name|'flavor'
op|'.'
name|'get_by_id'
op|'('
name|'self'
op|'.'
name|'context'
op|','
name|'db_flavor'
op|'['
string|"'id'"
op|']'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
op|'['
string|"'project1'"
op|','
string|"'project3'"
op|']'
op|','
name|'flavor'
op|'.'
name|'projects'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertRaises'
op|'('
name|'exception'
op|'.'
name|'FlavorAccessExists'
op|','
nl|'\n'
name|'flavor'
op|'.'
name|'add_access'
op|','
string|"'project1'"
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertRaises'
op|'('
name|'exception'
op|'.'
name|'FlavorAccessNotFound'
op|','
nl|'\n'
name|'flavor'
op|'.'
name|'remove_access'
op|','
string|"'project2'"
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_extra_specs_in_db
dedent|''
name|'def'
name|'test_extra_specs_in_db'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'db_flavor'
op|'='
name|'self'
op|'.'
name|'_create_api_flavor'
op|'('
name|'self'
op|'.'
name|'context'
op|')'
newline|'\n'
name|'flavor'
op|'='
name|'objects'
op|'.'
name|'Flavor'
op|'.'
name|'get_by_id'
op|'('
name|'self'
op|'.'
name|'context'
op|','
name|'db_flavor'
op|'['
string|"'id'"
op|']'
op|')'
newline|'\n'
name|'flavor'
op|'.'
name|'extra_specs'
op|'['
string|"'marty'"
op|']'
op|'='
string|"'mcfly'"
newline|'\n'
name|'del'
name|'flavor'
op|'.'
name|'extra_specs'
op|'['
string|"'foo'"
op|']'
newline|'\n'
name|'flavor'
op|'.'
name|'save'
op|'('
op|')'
newline|'\n'
name|'flavor'
op|'='
name|'objects'
op|'.'
name|'Flavor'
op|'.'
name|'get_by_id'
op|'('
name|'self'
op|'.'
name|'context'
op|','
name|'db_flavor'
op|'['
string|"'id'"
op|']'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
op|'{'
string|"'marty'"
op|':'
string|"'mcfly'"
op|'}'
op|','
name|'flavor'
op|'.'
name|'extra_specs'
op|')'
newline|'\n'
nl|'\n'
nl|'\n'
DECL|class|TestFlavorRemote
dedent|''
dedent|''
name|'class'
name|'TestFlavorRemote'
op|'('
name|'test_objects'
op|'.'
name|'_RemoteTest'
op|','
name|'_TestFlavor'
op|')'
op|':'
newline|'\n'
indent|'    '
name|'pass'
newline|'\n'
nl|'\n'
nl|'\n'
DECL|class|_TestFlavorList
dedent|''
name|'class'
name|'_TestFlavorList'
op|'('
name|'object'
op|')'
op|':'
newline|'\n'
indent|'    '
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.db.flavor_get_all'"
op|')'
newline|'\n'
DECL|member|test_get_all_from_db
name|'def'
name|'test_get_all_from_db'
op|'('
name|'self'
op|','
name|'mock_get'
op|')'
op|':'
newline|'\n'
comment|'# Get a list of the actual flavors in the API DB'
nl|'\n'
indent|'        '
name|'api_flavors'
op|'='
name|'flavor_obj'
op|'.'
name|'_flavor_get_all_from_db'
op|'('
name|'self'
op|'.'
name|'context'
op|','
nl|'\n'
name|'False'
op|','
name|'None'
op|','
nl|'\n'
string|"'flavorid'"
op|','
string|"'asc'"
op|','
nl|'\n'
name|'None'
op|','
name|'None'
op|')'
newline|'\n'
comment|'# Return a fake flavor from the main DB query'
nl|'\n'
name|'db_flavors'
op|'='
op|'['
name|'fake_flavor'
op|']'
newline|'\n'
name|'mock_get'
op|'.'
name|'return_value'
op|'='
name|'db_flavors'
newline|'\n'
nl|'\n'
name|'flavors'
op|'='
name|'objects'
op|'.'
name|'FlavorList'
op|'.'
name|'get_all'
op|'('
name|'self'
op|'.'
name|'context'
op|')'
newline|'\n'
comment|"# Make sure we're getting all flavors from the api and main"
nl|'\n'
comment|'# db queries'
nl|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
name|'len'
op|'('
name|'db_flavors'
op|')'
op|'+'
name|'len'
op|'('
name|'api_flavors'
op|')'
op|','
name|'len'
op|'('
name|'flavors'
op|')'
op|')'
newline|'\n'
nl|'\n'
DECL|member|test_get_all_from_db_with_limit
dedent|''
name|'def'
name|'test_get_all_from_db_with_limit'
op|'('
name|'self'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'flavors'
op|'='
name|'objects'
op|'.'
name|'FlavorList'
op|'.'
name|'get_all'
op|'('
name|'self'
op|'.'
name|'context'
op|','
nl|'\n'
name|'limit'
op|'='
number|'1'
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
number|'1'
op|','
name|'len'
op|'('
name|'flavors'
op|')'
op|')'
newline|'\n'
nl|'\n'
dedent|''
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.db.flavor_get_all'"
op|')'
newline|'\n'
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.flavor._flavor_get_all_from_db'"
op|')'
newline|'\n'
DECL|member|test_get_all
name|'def'
name|'test_get_all'
op|'('
name|'self'
op|','
name|'mock_api_get'
op|','
name|'mock_main_get'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'_fake_api_flavor'
op|'='
name|'dict'
op|'('
name|'fake_api_flavor'
op|','
nl|'\n'
name|'id'
op|'='
number|'2'
op|','
name|'name'
op|'='
string|"'m1.bar'"
op|','
name|'flavorid'
op|'='
string|"'m1.bar'"
op|')'
newline|'\n'
nl|'\n'
name|'mock_api_get'
op|'.'
name|'return_value'
op|'='
op|'['
name|'_fake_api_flavor'
op|']'
newline|'\n'
name|'mock_main_get'
op|'.'
name|'return_value'
op|'='
op|'['
name|'fake_flavor'
op|']'
newline|'\n'
name|'filters'
op|'='
op|'{'
string|"'min_memory_mb'"
op|':'
number|'4096'
op|'}'
newline|'\n'
name|'flavors'
op|'='
name|'flavor_obj'
op|'.'
name|'FlavorList'
op|'.'
name|'get_all'
op|'('
name|'self'
op|'.'
name|'context'
op|','
nl|'\n'
name|'inactive'
op|'='
name|'False'
op|','
nl|'\n'
name|'filters'
op|'='
name|'filters'
op|','
nl|'\n'
name|'sort_key'
op|'='
string|"'id'"
op|','
nl|'\n'
name|'sort_dir'
op|'='
string|"'asc'"
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
number|'2'
op|','
name|'len'
op|'('
name|'flavors'
op|')'
op|')'
newline|'\n'
name|'_TestFlavor'
op|'.'
name|'_compare'
op|'('
name|'self'
op|','
name|'_fake_api_flavor'
op|','
name|'flavors'
op|'['
number|'0'
op|']'
op|')'
newline|'\n'
name|'_TestFlavor'
op|'.'
name|'_compare'
op|'('
name|'self'
op|','
name|'fake_flavor'
op|','
name|'flavors'
op|'['
number|'1'
op|']'
op|')'
newline|'\n'
name|'mock_api_get'
op|'.'
name|'assert_called_once_with'
op|'('
name|'self'
op|'.'
name|'context'
op|','
name|'inactive'
op|'='
name|'False'
op|','
nl|'\n'
name|'filters'
op|'='
name|'filters'
op|','
name|'sort_key'
op|'='
string|"'id'"
op|','
nl|'\n'
name|'sort_dir'
op|'='
string|"'asc'"
op|','
name|'limit'
op|'='
name|'None'
op|','
nl|'\n'
name|'marker'
op|'='
name|'None'
op|')'
newline|'\n'
nl|'\n'
name|'mock_main_get'
op|'.'
name|'assert_called_once_with'
op|'('
name|'self'
op|'.'
name|'context'
op|','
name|'inactive'
op|'='
name|'False'
op|','
nl|'\n'
name|'filters'
op|'='
name|'filters'
op|','
name|'sort_key'
op|'='
string|"'id'"
op|','
nl|'\n'
name|'sort_dir'
op|'='
string|"'asc'"
op|','
name|'limit'
op|'='
name|'None'
op|','
nl|'\n'
name|'marker'
op|'='
name|'None'
op|')'
newline|'\n'
nl|'\n'
dedent|''
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.db.flavor_get_all'"
op|')'
newline|'\n'
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.flavor._flavor_get_all_from_db'"
op|')'
newline|'\n'
DECL|member|test_get_all_limit_applied_to_api
name|'def'
name|'test_get_all_limit_applied_to_api'
op|'('
name|'self'
op|','
name|'mock_api_get'
op|','
name|'mock_main_get'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'_fake_api_flavor'
op|'='
name|'dict'
op|'('
name|'fake_api_flavor'
op|','
nl|'\n'
name|'id'
op|'='
number|'2'
op|','
name|'name'
op|'='
string|"'m1.bar'"
op|','
name|'flavorid'
op|'='
string|"'m1.bar'"
op|')'
newline|'\n'
nl|'\n'
name|'mock_api_get'
op|'.'
name|'return_value'
op|'='
op|'['
name|'_fake_api_flavor'
op|']'
newline|'\n'
name|'mock_main_get'
op|'.'
name|'return_value'
op|'='
op|'['
name|'fake_flavor'
op|']'
newline|'\n'
name|'filters'
op|'='
op|'{'
string|"'min_memory_mb'"
op|':'
number|'4096'
op|'}'
newline|'\n'
name|'flavors'
op|'='
name|'flavor_obj'
op|'.'
name|'FlavorList'
op|'.'
name|'get_all'
op|'('
name|'self'
op|'.'
name|'context'
op|','
nl|'\n'
name|'inactive'
op|'='
name|'False'
op|','
nl|'\n'
name|'filters'
op|'='
name|'filters'
op|','
nl|'\n'
name|'limit'
op|'='
number|'2'
op|','
nl|'\n'
name|'sort_key'
op|'='
string|"'id'"
op|','
nl|'\n'
name|'sort_dir'
op|'='
string|"'asc'"
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
number|'2'
op|','
name|'len'
op|'('
name|'flavors'
op|')'
op|')'
newline|'\n'
name|'_TestFlavor'
op|'.'
name|'_compare'
op|'('
name|'self'
op|','
name|'_fake_api_flavor'
op|','
name|'flavors'
op|'['
number|'0'
op|']'
op|')'
newline|'\n'
name|'_TestFlavor'
op|'.'
name|'_compare'
op|'('
name|'self'
op|','
name|'fake_flavor'
op|','
name|'flavors'
op|'['
number|'1'
op|']'
op|')'
newline|'\n'
name|'mock_api_get'
op|'.'
name|'assert_called_once_with'
op|'('
name|'self'
op|'.'
name|'context'
op|','
name|'inactive'
op|'='
name|'False'
op|','
nl|'\n'
name|'filters'
op|'='
name|'filters'
op|','
name|'sort_key'
op|'='
string|"'id'"
op|','
nl|'\n'
name|'sort_dir'
op|'='
string|"'asc'"
op|','
name|'limit'
op|'='
number|'2'
op|','
nl|'\n'
name|'marker'
op|'='
name|'None'
op|')'
newline|'\n'
nl|'\n'
name|'mock_main_get'
op|'.'
name|'assert_called_once_with'
op|'('
name|'self'
op|'.'
name|'context'
op|','
name|'inactive'
op|'='
name|'False'
op|','
nl|'\n'
name|'filters'
op|'='
name|'filters'
op|','
name|'sort_key'
op|'='
string|"'id'"
op|','
nl|'\n'
name|'sort_dir'
op|'='
string|"'asc'"
op|','
name|'limit'
op|'='
number|'1'
op|','
nl|'\n'
name|'marker'
op|'='
name|'None'
op|')'
newline|'\n'
nl|'\n'
dedent|''
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.db.flavor_get_all'"
op|')'
newline|'\n'
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.flavor._flavor_get_all_from_db'"
op|')'
newline|'\n'
DECL|member|test_get_all_limit_no_main_call
name|'def'
name|'test_get_all_limit_no_main_call'
op|'('
name|'self'
op|','
name|'mock_api_get'
op|','
name|'mock_main_get'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'_fake_api_flavor'
op|'='
name|'dict'
op|'('
name|'fake_api_flavor'
op|','
nl|'\n'
name|'id'
op|'='
number|'2'
op|','
name|'name'
op|'='
string|"'m1.bar'"
op|','
name|'flavorid'
op|'='
string|"'m1.bar'"
op|')'
newline|'\n'
nl|'\n'
name|'mock_api_get'
op|'.'
name|'return_value'
op|'='
op|'['
name|'_fake_api_flavor'
op|']'
newline|'\n'
name|'mock_main_get'
op|'.'
name|'return_value'
op|'='
op|'['
name|'fake_flavor'
op|']'
newline|'\n'
name|'filters'
op|'='
op|'{'
string|"'min_memory_mb'"
op|':'
number|'4096'
op|'}'
newline|'\n'
name|'flavors'
op|'='
name|'flavor_obj'
op|'.'
name|'FlavorList'
op|'.'
name|'get_all'
op|'('
name|'self'
op|'.'
name|'context'
op|','
nl|'\n'
name|'inactive'
op|'='
name|'False'
op|','
nl|'\n'
name|'filters'
op|'='
name|'filters'
op|','
nl|'\n'
name|'limit'
op|'='
number|'1'
op|','
nl|'\n'
name|'sort_key'
op|'='
string|"'id'"
op|','
nl|'\n'
name|'sort_dir'
op|'='
string|"'asc'"
op|')'
newline|'\n'
name|'self'
op|'.'
name|'assertEqual'
op|'('
number|'1'
op|','
name|'len'
op|'('
name|'flavors'
op|')'
op|')'
newline|'\n'
name|'_TestFlavor'
op|'.'
name|'_compare'
op|'('
name|'self'
op|','
name|'_fake_api_flavor'
op|','
name|'flavors'
op|'['
number|'0'
op|']'
op|')'
newline|'\n'
name|'mock_api_get'
op|'.'
name|'assert_called_once_with'
op|'('
name|'self'
op|'.'
name|'context'
op|','
name|'inactive'
op|'='
name|'False'
op|','
nl|'\n'
name|'filters'
op|'='
name|'filters'
op|','
name|'sort_key'
op|'='
string|"'id'"
op|','
nl|'\n'
name|'sort_dir'
op|'='
string|"'asc'"
op|','
name|'limit'
op|'='
number|'1'
op|','
nl|'\n'
name|'marker'
op|'='
name|'None'
op|')'
newline|'\n'
nl|'\n'
name|'self'
op|'.'
name|'assertFalse'
op|'('
name|'mock_main_get'
op|'.'
name|'called'
op|')'
newline|'\n'
nl|'\n'
dedent|''
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.db.flavor_get_all'"
op|')'
newline|'\n'
op|'@'
name|'mock'
op|'.'
name|'patch'
op|'('
string|"'nova.objects.Flavor._flavor_get_query_from_db'"
op|')'
newline|'\n'
DECL|member|test_get_no_marker_in_api
name|'def'
name|'test_get_no_marker_in_api'
op|'('
name|'self'
op|','
name|'mock_api_get'
op|','
name|'mock_main_get'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'mock_api_get'
op|'.'
name|'filter_by'
op|'.'
name|'return_value'
op|'.'
name|'first'
op|'.'
name|'return_value'
op|'='
name|'None'
newline|'\n'
name|'mock_main_get'
op|'.'
name|'return_value'
op|'='
op|'['
op|']'
newline|'\n'
name|'flavor_obj'
op|'.'
name|'FlavorList'
op|'.'
name|'get_all'
op|'('
name|'self'
op|'.'
name|'context'
op|','
nl|'\n'
name|'inactive'
op|'='
name|'False'
op|','
nl|'\n'
name|'filters'
op|'='
name|'None'
op|','
nl|'\n'
name|'limit'
op|'='
number|'1'
op|','
nl|'\n'
name|'marker'
op|'='
string|"'foo'"
op|','
nl|'\n'
name|'sort_key'
op|'='
string|"'id'"
op|','
nl|'\n'
name|'sort_dir'
op|'='
string|"'asc'"
op|')'
newline|'\n'
name|'mock_main_get'
op|'.'
name|'assert_called_once_with'
op|'('
name|'self'
op|'.'
name|'context'
op|','
name|'inactive'
op|'='
name|'False'
op|','
nl|'\n'
name|'filters'
op|'='
name|'None'
op|','
name|'sort_key'
op|'='
string|"'id'"
op|','
nl|'\n'
name|'sort_dir'
op|'='
string|"'asc'"
op|','
name|'limit'
op|'='
number|'1'
op|','
nl|'\n'
name|'marker'
op|'='
name|'None'
op|')'
newline|'\n'
nl|'\n'
nl|'\n'
DECL|class|TestFlavorList
dedent|''
dedent|''
name|'class'
name|'TestFlavorList'
op|'('
name|'test_objects'
op|'.'
name|'_LocalTest'
op|','
name|'_TestFlavorList'
op|')'
op|':'
newline|'\n'
indent|'    '
name|'pass'
newline|'\n'
nl|'\n'
nl|'\n'
DECL|class|TestFlavorListRemote
dedent|''
name|'class'
name|'TestFlavorListRemote'
op|'('
name|'test_objects'
op|'.'
name|'_RemoteTest'
op|','
name|'_TestFlavorList'
op|')'
op|':'
newline|'\n'
indent|'    '
name|'pass'
newline|'\n'
dedent|''
endmarker|''
end_unit