horizon/horizon/test/utils.py
Richard Jones 9e09cfab2e Fix horizon/test selenium tests for Django 1.8
This fixes the dummy user used in the Selenium tests
for Django 1.8 updates (_meta.pk.to_python() etc strike
again).

It also addresses the refactoring of horizon.utils back
into angular code. This aspect of the patch, along with
the general structure of the test base.html, needs to
be revisited, but fixing that structure correctly is
outside of the scope of this patch.

Also the ObjDictWrapper was enhanced to allow easier
debugging of test failures, and simplified to reduce
LOC achieving the same functionality.

Change-Id: I5a50ad89163a8cce06959d36314a836c4bd3592c
Closes-Bug: 1501163
2015-09-30 16:41:30 +10:00

29 lines
1.0 KiB
Python

# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
class ObjDictWrapper(dict):
"""ObjDictWrapper is a container that provides both dictionary-like and
object-like attribute access.
"""
def __getattr__(self, item):
if item in self:
return self[item]
else:
raise AttributeError(item)
def __setattr__(self, item, value):
self[item] = value
def __repr__(self):
return '<ObjDictWrapper %s>' % super(ObjDictWrapper, self).__repr__()