def test_prefixes(self): request, library, definition, group_a, group_b = self._fixtures() from uu.formlibrary.forms import ComposedForm composed = ComposedForm(definition, request) composed.updateFields() assert composed.getPrefix(group_b.schema) == group_b.getId() assert composed.getPrefix(definition.schema) == '' # group_a is a special case, it is a grid, so its schema is wrapped # in another schema -- indirectly part of form composition: assert composed.getPrefix(group_a.schema) != group_a.getId() # however: from uu.formlibrary.forms import is_grid_wrapper_schema schemas = [t[1] for t in composed.group_schemas] wrapper = [s for s in schemas if is_grid_wrapper_schema(s)][0] assert composed.getPrefix(wrapper) == group_a.getId()
def test_composed_no_schema(self): request, library, definition, group_a, group_b = self._fixtures() contained = definition.contentValues() assert group_a in contained assert group_b in contained from uu.formlibrary.forms import ComposedForm composed_prior_to_schema = ComposedForm(definition, request) composed_prior_to_schema.updateFields() # it isn't that there is no schema, it is that the schema is the # empty default. assert definition.schema is composed_prior_to_schema.schema # group A schema is a grid, should not be in additionalSchemata: assert group_a.schema not in composed_prior_to_schema.additionalSchemata # group B schema is not a grid, but direct fieldset-like construct, # therefore should be in additionalSchemata assert group_b.schema in composed_prior_to_schema.additionalSchemata assert len(composed_prior_to_schema.additionalSchemata) == 2