Ejemplo n.º 1
0
def test_resolve_field_class():
    """Test looking up field by field $type"""
    # Check for error on known invalid type
    with pytest.raises(KeyError):
        resolve_field_class({'$type': 'Not a valid type'})

    # Check all fields with a type are resolvable by their types
    for cls in get_recursive_subclasses(Field):
        if cls.field_type:
            if isinstance(cls.field_type, six.string_types):
                types = [cls.field_type]
            else:
                types = cls.field_type

            for field_type in types:
                assert resolve_field_class({'$type': field_type}) is cls
Ejemplo n.º 2
0
    def __premap_fields(self):
        """Build field instances using field definitions in app manifest
        
        Map raw record field data into appropriate field instances with their correct respective types
        """
        # Circular imports
        from swimlane.core.fields import resolve_field_class

        for field_definition in self.app._raw['fields']:
            field_class = resolve_field_class(field_definition)

            field_instance = field_class(field_definition['name'], self)
            value = self._raw['values'].get(field_instance.id)
            field_instance.set_swimlane(value)

            self._fields[field_instance.name] = field_instance
Ejemplo n.º 3
0
def test_resolve_field_class():
    """Test looking up field by field $type"""
    with pytest.raises(KeyError):
        resolve_field_class({'$type': 'Not a valid type'})