def test_set_tag_value(self):
        # set stuff up...
        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, root_path)
        # Empty tags allowed
        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))
        # Empty tags are *not* allowed
        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))
        # tag values have been set except for the one that was None
        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/original