

def test_set_tag_value(self):
    name = str(uuid.uuid4())
    root_path = ('test/%s' % name)
    template = [{
        'foo': None,
        'bar': {
            'baz': '',
        },
        'bof': 'Hello',
        'qux': False,
    }]
    tags = create_schema(template, root_path, 'flimp_test', 'flimp unit-test suite')
    self.assertEqual(4, len(tags))
    fom_class = create_class(tags)
    test_item = template[0]
    tag_values = get_values(test_item, template)
    allowEmpty = True
    obj = fom_class()
    obj.create()
    for (key, value) in tag_values.iteritems():
        set_tag_value(fom_class, obj, key, value, allowEmpty)
    self.assertEqual(None, getattr(obj, ('test/%s/foo' % name)))
    self.assertEqual('', getattr(obj, ('test/%s/bar/baz' % name)))
    self.assertEqual('Hello', getattr(obj, ('test/%s/bof' % name)))
    self.assertEqual(False, getattr(obj, ('test/%s/qux' % name)))
    allowEmpty = False
    obj = fom_class()
    obj.create()
    for (key, value) in tag_values.iteritems():
        set_tag_value(fom_class, obj, key, value, allowEmpty)
    tags = obj.tags
    self.assertEqual(3, len(tags))
    self.assertEqual('', getattr(obj, ('test/%s/bar/baz' % name)))
    self.assertEqual('Hello', getattr(obj, ('test/%s/bof' % name)))
    self.assertEqual(False, getattr(obj, ('test/%s/qux' % name)))

dataset/ETHPy150Open fluidinfo/flimp/tests/test_utils.py TestUtils.test_set_tag_value/VarMisuse@109/162 `root_path`->`template`