blob: 440750290dc1360e7b31cf2f767bfa312db2e3ef [file] [log] [blame]
#!/usr/bin/env python
#
# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# pylint: disable=E1101
import unittest
import factory_common # pylint: disable=W0611
from cros.factory.common import AttrDict
class CommonTest(unittest.TestCase):
def testAttrDictInit(self):
init_value = {
'key': 'value_1',
'keydict': {'key2': 'value_key2_2'},
'keylist': [0, 1, 2, {'key3': 'value_keylist_3_key3'}, 4]}
adict = AttrDict(init_value)
self.assertEqual('value_1', adict.key)
self.assertEqual('value_key2_2', adict.keydict.key2)
self.assertEqual('value_keylist_3_key3', adict.keylist[3].key3)
def testAttrDictSetGet(self):
adict = AttrDict()
adict['foo'] = 'bar'
self.assertEqual('bar', adict.foo)
adict.somekey = 'blah'
self.assertEqual('blah', adict['somekey'])
if __name__ == '__main__':
unittest.main()