begin_unit
comment|'# Copyright 2011 OpenStack Foundation'
nl|'\n'
comment|'# All Rights Reserved.'
nl|'\n'
comment|'#'
nl|'\n'
comment|'#    Licensed under the Apache License, Version 2.0 (the "License"); you may'
nl|'\n'
comment|'#    not use this file except in compliance with the License. You may obtain'
nl|'\n'
comment|'#    a copy of the License at'
nl|'\n'
comment|'#'
nl|'\n'
comment|'#         http://www.apache.org/licenses/LICENSE-2.0'
nl|'\n'
comment|'#'
nl|'\n'
comment|'#    Unless required by applicable law or agreed to in writing, software'
nl|'\n'
comment|'#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT'
nl|'\n'
comment|'#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the'
nl|'\n'
comment|'#    License for the specific language governing permissions and limitations'
nl|'\n'
comment|'#    under the License.'
nl|'\n'
nl|'\n'
name|'from'
name|'oslo_serialization'
name|'import'
name|'jsonutils'
newline|'\n'
name|'import'
name|'webob'
newline|'\n'
nl|'\n'
nl|'\n'
DECL|function|webob_factory
name|'def'
name|'webob_factory'
op|'('
name|'url'
op|')'
op|':'
newline|'\n'
indent|'    '
string|'"""Factory for removing duplicate webob code from tests."""'
newline|'\n'
nl|'\n'
name|'base_url'
op|'='
name|'url'
newline|'\n'
nl|'\n'
DECL|function|web_request
name|'def'
name|'web_request'
op|'('
name|'url'
op|','
name|'method'
op|'='
name|'None'
op|','
name|'body'
op|'='
name|'None'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'req'
op|'='
name|'webob'
op|'.'
name|'Request'
op|'.'
name|'blank'
op|'('
string|'"%s%s"'
op|'%'
op|'('
name|'base_url'
op|','
name|'url'
op|')'
op|')'
newline|'\n'
name|'if'
name|'method'
op|':'
newline|'\n'
indent|'            '
name|'req'
op|'.'
name|'content_type'
op|'='
string|'"application/json"'
newline|'\n'
name|'req'
op|'.'
name|'method'
op|'='
name|'method'
newline|'\n'
dedent|''
name|'if'
name|'body'
op|':'
newline|'\n'
indent|'            '
name|'req'
op|'.'
name|'body'
op|'='
name|'jsonutils'
op|'.'
name|'dump_as_bytes'
op|'('
name|'body'
op|')'
newline|'\n'
dedent|''
name|'return'
name|'req'
newline|'\n'
dedent|''
name|'return'
name|'web_request'
newline|'\n'
nl|'\n'
nl|'\n'
DECL|function|compare_links
dedent|''
name|'def'
name|'compare_links'
op|'('
name|'actual'
op|','
name|'expected'
op|')'
op|':'
newline|'\n'
indent|'    '
string|'"""Compare xml atom links."""'
newline|'\n'
nl|'\n'
name|'return'
name|'compare_tree_to_dict'
op|'('
name|'actual'
op|','
name|'expected'
op|','
op|'('
string|"'rel'"
op|','
string|"'href'"
op|','
string|"'type'"
op|')'
op|')'
newline|'\n'
nl|'\n'
nl|'\n'
DECL|function|compare_media_types
dedent|''
name|'def'
name|'compare_media_types'
op|'('
name|'actual'
op|','
name|'expected'
op|')'
op|':'
newline|'\n'
indent|'    '
string|'"""Compare xml media types."""'
newline|'\n'
nl|'\n'
name|'return'
name|'compare_tree_to_dict'
op|'('
name|'actual'
op|','
name|'expected'
op|','
op|'('
string|"'base'"
op|','
string|"'type'"
op|')'
op|')'
newline|'\n'
nl|'\n'
nl|'\n'
DECL|function|compare_tree_to_dict
dedent|''
name|'def'
name|'compare_tree_to_dict'
op|'('
name|'actual'
op|','
name|'expected'
op|','
name|'keys'
op|')'
op|':'
newline|'\n'
indent|'    '
string|'"""Compare parts of lxml.etree objects to dicts."""'
newline|'\n'
nl|'\n'
name|'for'
name|'elem'
op|','
name|'data'
name|'in'
name|'zip'
op|'('
name|'actual'
op|','
name|'expected'
op|')'
op|':'
newline|'\n'
indent|'        '
name|'for'
name|'key'
name|'in'
name|'keys'
op|':'
newline|'\n'
indent|'            '
name|'if'
name|'elem'
op|'.'
name|'get'
op|'('
name|'key'
op|')'
op|'!='
name|'data'
op|'.'
name|'get'
op|'('
name|'key'
op|')'
op|':'
newline|'\n'
indent|'                '
name|'return'
name|'False'
newline|'\n'
dedent|''
dedent|''
dedent|''
name|'return'
name|'True'
newline|'\n'
dedent|''
endmarker|''
end_unit
