예제 #1
0
 def __init__(self, *args, **kwargs):
     """Returns new Info object. Creates DbRefs if necessary."""
     temp = dict(*args, **kwargs)
     if 'Refs' in temp:
         refs = temp['Refs']
         if not isinstance(refs, DbRefs):
             refs = DbRefs(refs)
     else:
         refs = DbRefs()
     #move keys into refs if they belong there: allows init from flat dict 
     for key, val in temp.items():
         if key in KnownDatabases:
             refs[key] = val
             del temp[key]
             
     Delegator.__init__(self, refs)
     self['Refs'] = refs
     MappedRecord.__init__(self, temp)
예제 #2
0
 def setUp(self):
     """Define a few standard MappedRecords"""
     self.empty = MappedRecord()
     self.single = MappedRecord({'a': 3})
     self.several = MappedRecord(a=4, b=5, c='a', d=[1, 2, 3])
예제 #3
0
 def test_init_empty(self):
     """MappedRecord empty init should work OK"""
     g = MappedRecord()
     self.assertEqual(g, {})
예제 #4
0
 def test_init_data(self):
     """MappedRecord should work like normal dict init"""
     exp = {'a': 3, 'b': 4}
     self.assertEqual(MappedRecord({'a': 3, 'b': 4}), exp)
     self.assertEqual(MappedRecord(a=3, b=4), exp)
     self.assertEqual(MappedRecord([['a', 3], ['b', 4]]), exp)