def setUp(self):
     init_annalist_test_site()
     self.testsite   = Site(TestBaseUri, TestBaseDir)
     self.testcoll   = Collection(self.testsite, "testcoll")
     self.testcoll1  = Collection(self.testsite, "testcoll1")
     self.testcoll2  = Collection(self.testsite, "testcoll2")
     self.fieldcache = CollectionFieldCache()
     self.field1     = RecordField(self.testcoll1, "field1")
     self.field1.set_values(
         recordfield_create_values(field_id="field1", property_uri="test:field1", 
             superproperty_uris=[]
             )
         )
     self.field11   = RecordField(self.testcoll1, "field11")
     self.field11.set_values(
         recordfield_create_values(field_id="field11", property_uri="test:field11", 
             superproperty_uris=["test:field1"]
             )
         )
     self.field111  = RecordField(self.testcoll1, "field111")
     self.field111.set_values(
         recordfield_create_values(field_id="field111", property_uri="test:field111", 
             superproperty_uris=["test:field11"]
             )
         )
     self.field2    = RecordField(self.testcoll1, "field2")
     self.field2.set_values(
         recordfield_create_values(field_id="field2", property_uri="test:field2", 
             superproperty_uris=[]
             )
         )
     return
 def create_subproperty_field_view_entity(self):
     # Create test field using superproperty
     self.test_sup_field = RecordField.create(self.testcoll, "Test_sup_field",
         { ANNAL.CURIE.type:                 "annal:Field"
         , RDFS.CURIE.label:                 "Field using superproperty URI"
         , RDFS.CURIE.comment:               "Field using superproperty URI"
         , ANNAL.CURIE.field_render_type:    "_enum_render_type/Text"
         , ANNAL.CURIE.field_value_mode:     "_enum_value_mode/Value_direct"
         , ANNAL.CURIE.field_entity_type:    "test:testtype"
         , ANNAL.CURIE.placeholder:          "(Test_sup_field)"
         , ANNAL.CURIE.property_uri:         "test:superprop_uri"
         , ANNAL.CURIE.field_placement:      "small:0,12;medium:0,6"
         })
     self.assertTrue(self.test_sup_field is not None)
     # Create test field using subproperty and declaring superproperty
     self.test_sub_field = RecordField.create(self.testcoll, "Test_sub_field",
         { ANNAL.CURIE.type:                 "annal:Field"
         , RDFS.CURIE.label:                 "Field using superproperty URI"
         , RDFS.CURIE.comment:               "Field using superproperty URI"
         , ANNAL.CURIE.field_render_type:    "_enum_render_type/Text"
         , ANNAL.CURIE.field_value_mode:     "_enum_value_mode/Value_direct"
         , ANNAL.CURIE.field_entity_type:    "test:testtype"
         , ANNAL.CURIE.placeholder:          "(Test_sub_field)"
         , ANNAL.CURIE.property_uri:         "test:subprop_uri"
         , ANNAL.CURIE.superproperty_uri:    [{"@id": "test:superprop_uri"}]
         , ANNAL.CURIE.field_placement:      "small:0,12;medium:0,6"
         })
     self.assertTrue(self.test_sub_field is not None)
     # Create test view using superproperty
     self.test_view = RecordView.create(self.testcoll, "testview",
         { ANNAL.CURIE.type:             "annal:View"
         , ANNAL.CURIE.uri:              "test:view"
         , RDFS.CURIE.label:             "Test view label"
         , RDFS.CURIE.comment:           "Test view comment"
         , ANNAL.CURIE.view_entity_type: "test:testtype"
         , ANNAL.CURIE.view_fields:
           [ { ANNAL.CURIE.field_id:         layout.FIELD_TYPEID+"/Entity_id"
             , ANNAL.CURIE.field_placement:  "small:0,12;medium:0,6"
             }
           , { ANNAL.CURIE.field_id:         layout.FIELD_TYPEID+"/Test_sup_field"
             , ANNAL.CURIE.field_placement:  "small:0,12;medium:0,6"
             }
           ]
         })
     self.assertTrue(self.test_view is not None)
     # Create test entity using subproperty
     self.testentity_data = EntityData.create(self.testdata, "testentity", 
         entitydata_create_values(
             "testentity", type_id="testtype",
             type_uri="test:testtype",
             extra_fields={"test:subprop_uri": "Test field value"} 
             )
         )
     self.assertTrue(self.testentity_data is not None)
     return
Exemple #3
0
def field_description_from_view_field(collection,
                                      field,
                                      view_context=None,
                                      group_ids_seen=[]):
    """
    Returns a field description value created using information from
    a field reference in a view description record (i.e. a dictionary
    containing a field id value and optional field property URI and
    placement values.  (The optional values, if not provided, are 
    obtained from the referenced field description)

    collection      is a collection from which data is being rendered.
    field           is a dictionary with the field description from a view or list 
                    description, containing a field id and placement values.
    view_context    is a dictionary of additional values that may be used in assembling
                    values to be used when rendering the field.  In particular, a copy 
                    of the view description record provides context for some enumeration 
                    type selections.
    group_ids_seen  group ids expanded so far, to check for recursive reference.
    """
    #@@TODO: for resilience, revert this when all tests pass?
    # field_id    = field.get(ANNAL.CURIE.field_id, "Field_id_missing")  # Field ID slug in URI
    #@@
    field_id = extract_entity_id(field[ANNAL.CURIE.field_id])
    recordfield = RecordField.load(collection, field_id, altscope="all")
    if recordfield is None:
        log.warning("Can't retrieve definition for field %s" % (field_id))
        recordfield = RecordField.load(collection,
                                       "Field_missing",
                                       altscope="all")
    # If field references group, pull in group details
    group_ref = extract_entity_id(recordfield.get(ANNAL.CURIE.group_ref, None))
    if group_ref:
        group_view = RecordGroup.load(collection, group_ref, altscope="all")
        if not group_view:
            log.error("Group %s used in field %s" % (group_ref, field_id))
            # log.error("".join(traceback.format_stack()))
            # ex_type, ex, tb = sys.exc_info()
            # traceback.print_tb(tb)
            # raise EntityNotFound_Error("Group %s used in field %s"%(group_ref, field_id))
    else:
        group_view = None
    # If present, `field_property` and `field_placement` override values in the field dexcription
    return FieldDescription(collection,
                            recordfield,
                            view_context=view_context,
                            field_property=field.get(ANNAL.CURIE.property_uri,
                                                     None),
                            field_placement=field.get(
                                ANNAL.CURIE.field_placement, None),
                            group_view=group_view,
                            group_ids_seen=group_ids_seen)
Exemple #4
0
 def setUp(self):
     init_annalist_test_site()
     self.testsite = Site(TestBaseUri, TestBaseDir)
     self.testcoll = Collection(self.testsite, "testcoll")
     self.testcoll1 = Collection(self.testsite, "testcoll1")
     self.testcoll2 = Collection(self.testsite, "testcoll2")
     self.fieldcache = CollectionFieldCache()
     self.field1 = RecordField(self.testcoll1, "field1")
     self.field1.set_values(
         recordfield_create_values(field_id="field1",
                                   property_uri="test:field1",
                                   superproperty_uris=[]))
     self.field11 = RecordField(self.testcoll1, "field11")
     self.field11.set_values(
         recordfield_create_values(field_id="field11",
                                   property_uri="test:field11",
                                   superproperty_uris=["test:field1"]))
     self.field111 = RecordField(self.testcoll1, "field111")
     self.field111.set_values(
         recordfield_create_values(field_id="field111",
                                   property_uri="test:field111",
                                   superproperty_uris=["test:field11"]))
     self.field2 = RecordField(self.testcoll1, "field2")
     self.field2.set_values(
         recordfield_create_values(field_id="field2",
                                   property_uri="test:field2",
                                   superproperty_uris=[]))
     return
def field_description_from_view_field(collection, field, view_context=None):
    """
    Returns a field description value created using information from
    a field reference in a view description record (i.e. a dictionary
    containing a field id value and optional field property URI and
    placement values.  (The optional values, if not provided, are 
    obtained from the referenced field descriptionb)

    collection      is a collection from which data is being rendered.
    field           is a dictionary with the field description from a view or list 
                    description, containing a field id and placement values.
    view_context    is a dictionary of additional values that may be used in assembling
                    values to be used when rendering the field.  In particular, a copy 
                    of the view description record provides context for some enumeration 
                    type selections.
    """
    #@@TODO: for resilience, revert this when all tests pass?
    # field_id    = field.get(ANNAL.CURIE.field_id, "Field_id_missing")  # Field ID slug in URI
    #@@
    field_id = field[ANNAL.CURIE.field_id]
    recordfield = RecordField.load(collection, field_id,
                                   collection._parentsite)
    if recordfield is None:
        log.warning("Can't retrieve definition for field %s" % (field_id))
        recordfield = RecordField.load(collection, "Field_missing",
                                       collection._parentsite)
    field_property = (field.get(ANNAL.CURIE.property_uri, None)
                      or recordfield.get(ANNAL.CURIE.property_uri, ""))
    field_placement = get_placement_classes(
        field.get(ANNAL.CURIE.field_placement, None)
        or recordfield.get(ANNAL.CURIE.field_placement, ""))
    # If field references group, pull in field details
    group_ref = recordfield.get(ANNAL.CURIE.group_ref, None)
    if group_ref:
        group_view = RecordGroup.load(collection, group_ref,
                                      collection._parentsite)
        if not group_view:
            raise EntityNotFound_Error("Group %s used in field %s" %
                                       (group_ref, field_id))
    else:
        group_view = None
    return FieldDescription(collection,
                            recordfield,
                            view_context=view_context,
                            field_property=field.get(ANNAL.CURIE.property_uri,
                                                     None),
                            field_placement=field.get(
                                ANNAL.CURIE.field_placement, None),
                            group_view=group_view)
 def setUp(self):
     init_annalist_test_site()
     init_annalist_test_coll()
     self.testsite    = Site(TestBaseUri, TestBaseDir)
     self.testcoll    = Collection(self.testsite, "testcoll")
     # Populate collection with linked record types, views and lists
     self.testsrc_type = RecordType.create(self.testcoll, "testsrc_type", testsrc_type_create_values)
     self.testtgt_type = RecordType.create(self.testcoll, "testtgt_type", testtgt_type_create_values)
     self.testsrc_view = RecordView.create(self.testcoll, "testsrc_view", testsrc_view_create_values)
     self.testtgt_view = RecordView.create(self.testcoll, "testtgt_view", testtgt_view_create_values)
     self.testsrc_list = RecordList.create(self.testcoll, "testsrc_list", testsrc_list_create_values)
     self.testtgt_list = RecordList.create(self.testcoll, "testtgt_list", testtgt_list_create_values)
     self.testtgtref_field = RecordField.create(self.testcoll, "testtgtref_field", testtgtref_field_create_values)
     self.no_options   = [ FieldChoice('', label="(no options)") ]
     self.tgt_options  = (
         [ FieldChoice("testtgt_type/"+v, 
             label="testtgt_entity %s label"%v,
             link=entity_url("testcoll", "testtgt_type", v))
           for v in ["testtgt1", "testtgt2"]
         ])
     # Create data records for testing:
     self.testtgt_type_info = EntityTypeInfo(self.testcoll, "testtgt_type", create_typedata=True)
     self.testsrc_type_info = EntityTypeInfo(self.testcoll, "testsrc_type", create_typedata=True)
     for tgt_id in ("testtgt1", "testtgt2"):
         self.testtgt_type_info.create_entity(tgt_id, testtgt_entity_create_values(tgt_id))
     for src_id, tgt_ref in (("testsrc1", "testtgt1"), ("testsrc2", "testtgt2")):
         self.testsrc_type_info.create_entity(src_id, testsrc_entity_create_values(src_id, tgt_ref))
     # Login and permissions
     create_test_user(self.testcoll, "testuser", "testpassword")
     self.client = Client(HTTP_HOST=TestHost)
     loggedin = self.client.login(username="******", password="******")
     self.assertTrue(loggedin)
     return
Exemple #7
0
 def setUp(self):
     self.filepath  = "%s/README.md"%TestBaseDir
     self.fileuri   = "file://"+self.filepath
     self.imagepath = "%s/test-image.jpg"%TestBaseDir
     self.imageuri  = "file://"+self.filepath
     init_annalist_test_site()
     init_annalist_test_coll()
     self.testsite    = Site(TestBaseUri, TestBaseDir)
     self.testcoll    = Collection(self.testsite, "testcoll")
     # Populate collection with record type, view and field
     self.test_ref_type = RecordType.create(
         self.testcoll, "testreftype", test_image_ref_type_create_values
         )
     self.test_ref_view = RecordView.create(
         self.testcoll, "testrefview", test_image_ref_view_create_values
         )
     self.test_ref_field = RecordField.create(
         self.testcoll, "Test_image_ref", test_image_ref_field_create_values
         )
     # Create data records for testing image references:
     self.test_ref_type_info = EntityTypeInfo(
         self.testcoll, "testreftype", create_typedata=True
         )
     self.test_ref_type_info.create_entity("test1", test_ref_entity_create_values(self.imageuri))
     # Login and permissions
     create_test_user(self.testcoll, "testuser", "testpassword")
     self.client = Client(HTTP_HOST=TestHost)
     loggedin = self.client.login(username="******", password="******")
     self.assertTrue(loggedin)
     return
Exemple #8
0
 def setUp(self):
     self.filepath  = "%s/README.md"%TestBaseDir
     self.fileuri   = "file://"+self.filepath
     self.imagepath = "%s/test-image.jpg"%TestBaseDir
     self.imageuri  = "file://"+self.filepath
     init_annalist_test_site()
     init_annalist_test_coll()
     self.testsite    = Site(TestBaseUri, TestBaseDir)
     self.testcoll    = Collection(self.testsite, "testcoll")
     # Populate collection with record type, view and field
     self.test_ref_type = RecordType.create(
         self.testcoll, "testreftype", test_image_ref_type_create_values
         )
     self.test_ref_view = RecordView.create(
         self.testcoll, "testrefview", test_image_ref_view_create_values
         )
     self.test_ref_field = RecordField.create(
         self.testcoll, "Test_image_ref", test_image_ref_field_create_values
         )
     # Create data records for testing image references:
     self.test_ref_type_info = EntityTypeInfo(
         self.testcoll, "testreftype", create_typedata=True
         )
     self.test_ref_type_info.create_entity("test1", test_ref_entity_create_values(self.imageuri))
     # Login and permissions
     create_test_user(self.testcoll, "testuser", "testpassword")
     self.client = Client(HTTP_HOST=TestHost)
     loggedin = self.client.login(username="******", password="******")
     self.assertTrue(loggedin)
     return
Exemple #9
0
 def setUp(self):
     self.fileuri = "file://%s/README.md"%TestBaseDir
     init_annalist_test_site()
     init_annalist_test_coll()
     self.testsite    = Site(TestBaseUri, TestBaseDir)
     self.testcoll    = Collection(self.testsite, "testcoll")
     # Populate collection with linked record types, views and lists
     self.test_imp_type = RecordType.create(
         self.testcoll, "testimptype", test_import_type_create_values
         )
     self.test_imp_view = RecordView.create(
         self.testcoll, "testimpview", test_import_view_create_values
         )
     self.test_imp_field = RecordField.create(
         self.testcoll, "Test_import", test_import_field_create_values
         )
     self.test_ref_type = RecordType.create(
         self.testcoll, "testreftype", test_reference_type_create_values
         )
     self.test_ref_view = RecordView.create(
         self.testcoll, "testrefview", test_reference_view_create_values
         )
     self.test_ref_field = RecordField.create(
         self.testcoll, "Test_reference", test_reference_field_create_values
         )
     # Create data records for testing import and references:
     self.test_imp_type_info = EntityTypeInfo(
         self.testcoll, "testimptype", create_typedata=True
         )
     for entity_id in ("test1", "test2"):
         self.test_imp_type_info.create_entity(
             entity_id, test_imp_entity_create_values(entity_id)
             )
     self.test_ref_type_info = EntityTypeInfo(
         self.testcoll, "testreftype", create_typedata=True
         )
     for entity_id in ("test1", "test2"):
         self.test_ref_type_info.create_entity(
             entity_id, test_ref_entity_create_values(entity_id)
             )
     # Login and permissions
     create_test_user(self.testcoll, "testuser", "testpassword")
     self.client = Client(HTTP_HOST=TestHost)
     loggedin = self.client.login(username="******", password="******")
     self.assertTrue(loggedin)
     return
 def setUp(self):
     self.fileuri = "file://%s/README.md"%TestBaseDir
     init_annalist_test_site()
     init_annalist_test_coll()
     self.testsite    = Site(TestBaseUri, TestBaseDir)
     self.testcoll    = Collection(self.testsite, "testcoll")
     # Populate collection with linked record types, views and lists
     self.test_imp_type = RecordType.create(
         self.testcoll, "testimptype", test_import_type_create_values
         )
     self.test_imp_view = RecordView.create(
         self.testcoll, "testimpview", test_import_view_create_values
         )
     self.test_imp_field = RecordField.create(
         self.testcoll, "Test_import", test_import_field_create_values
         )
     self.test_ref_type = RecordType.create(
         self.testcoll, "testreftype", test_reference_type_create_values
         )
     self.test_ref_view = RecordView.create(
         self.testcoll, "testrefview", test_reference_view_create_values
         )
     self.test_ref_field = RecordField.create(
         self.testcoll, "Test_reference", test_reference_field_create_values
         )
     # Create data records for testing import and references:
     self.test_imp_type_info = EntityTypeInfo(
         self.testcoll, "testimptype", create_typedata=True
         )
     for entity_id in ("test1", "test2"):
         self.test_imp_type_info.create_entity(
             entity_id, test_imp_entity_create_values(entity_id)
             )
     self.test_ref_type_info = EntityTypeInfo(
         self.testcoll, "testreftype", create_typedata=True
         )
     for entity_id in ("test1", "test2"):
         self.test_ref_type_info.create_entity(
             entity_id, test_ref_entity_create_values(entity_id)
             )
     # Login and permissions
     create_test_user(self.testcoll, "testuser", "testpassword")
     self.client = Client(HTTP_HOST=TestHost)
     loggedin = self.client.login(username="******", password="******")
     self.assertTrue(loggedin)
     return
def field_description_from_view_field(collection, field, view_context=None, group_ids_seen=[]):
    """
    Returns a field description value created using information from
    a field reference in a view description record (i.e. a dictionary
    containing a field id value and optional field property URI and
    placement values.  (The optional values, if not provided, are 
    obtained from the referenced field description)

    collection      is a collection from which data is being rendered.
    field           is a dictionary with the field description from a view or list 
                    description, containing a field id and placement values.
    view_context    is a dictionary of additional values that may be used in assembling
                    values to be used when rendering the field.  In particular, a copy 
                    of the view description record provides context for some enumeration 
                    type selections.
    group_ids_seen  group ids expanded so far, to check for recursive reference.
    """
    #@@TODO: for resilience, revert this when all tests pass?
    # field_id    = field.get(ANNAL.CURIE.field_id, "Field_id_missing")  # Field ID slug in URI
    #@@
    field_id    = extract_entity_id(field[ANNAL.CURIE.field_id])
    recordfield = RecordField.load(collection, field_id, altscope="all")
    if recordfield is None:
        log.warning("Can't retrieve definition for field %s"%(field_id))
        recordfield = RecordField.load(collection, "Field_missing", altscope="all")
    # If field references group, pull in group details
    group_ref = extract_entity_id(recordfield.get(ANNAL.CURIE.group_ref, None))
    if group_ref:
        group_view = RecordGroup.load(collection, group_ref, altscope="all")
        if not group_view:
            log.error("Group %s used in field %s"%(group_ref, field_id))
            # log.error("".join(traceback.format_stack()))
            # ex_type, ex, tb = sys.exc_info()
            # traceback.print_tb(tb)
            # raise EntityNotFound_Error("Group %s used in field %s"%(group_ref, field_id))
    else:
        group_view = None
    # If present, `field_property` and `field_placement` override values in the field dexcription
    return FieldDescription(
        collection, recordfield, view_context=view_context, 
        field_property=field.get(ANNAL.CURIE.property_uri, None),
        field_placement=field.get(ANNAL.CURIE.field_placement, None), 
        group_view=group_view,
        group_ids_seen=group_ids_seen
        )
Exemple #12
0
    def cache_get_field(self, field_id):
        """
        Retrieve field from cache.

        Returns field entity if found, otherwise None.
        """
        #@@ field_cache.get_field(self, field_id)
        t = field_cache.get_field(self, field_id)
        # Was it previously created but not cached?
        if not t and RecordField.exists(self, field_id, altscope="all"):
            msg = (
                "Collection.get_field %s present but not cached for collection %s"%
                (field_id, self.get_id())
                )
            log.warning(msg)
            t = RecordField.load(self, field_id, altscope="all")
            field_cache.set_field(self, t)
        return t
Exemple #13
0
    def cache_get_field(self, field_id):
        """
        Retrieve field from cache.

        Returns field entity if found, otherwise None.
        """
        field_cache.get_field(self, field_id)
        t = field_cache.get_field(self, field_id)
        # Was it previously created but not cached?
        if not t and RecordField.exists(self, field_id, altscope="all"):
            msg = (
                "Collection.get_field %s present but not cached for collection %s"%
                (field_id, self.get_id())
                )
            log.warning(msg)
            t = RecordField.load(self, field_id, altscope="all")
            field_cache.set_field(self, t)
        return t
Exemple #14
0
    def remove_field(self, field_id):
        """
        Remove identified field description

        field_id     local identifier for the field to remove.

        Returns None on success, or a non-False status code if the field is not removed.
        """
        s = RecordField.remove(self, field_id)
        return s
Exemple #15
0
    def remove_field(self, field_id):
        """
        Remove identified field description

        field_id     local identifier for the field to remove.

        Returns None on success, or a non-False status code if the field is not removed.
        """
        s = RecordField.remove(self, field_id)
        return s
Exemple #16
0
 def _create_refimg_image_field(self):
     refimg_image_field = RecordField.create(self.testcoll, "Test_image",
         { "annal:type":                 "annal:Field"
         , "rdfs:label":                 "View image field"
         , "rdfs:comment":               "In view mode, displays an image."
         , "annal:field_render_type":    "RefImage"
         , "annal:field_value_mode":     "Value_direct"
         , "annal:field_value_type":    "annal:Image"
         , "annal:field_entity_type":    "test:img_type"
         , "annal:placeholder":          "(view image field)"
         , "annal:property_uri":         "test:image"
         , "annal:field_placement":      "small:0,12;medium:0,6"
         })
     return refimg_image_field
Exemple #17
0
 def _create_refimg_comment_field(self):
     refimg_comment_field = RecordField.create(self.testcoll, "Test_comment",
         { "annal:type":                 "annal:Field"
         , "rdfs:label":                 "View comment field"
         , "rdfs:comment":               "In view mode, displays a comment."
         , "annal:field_render_type":    "Markdown"
         , "annal:field_value_mode":     "Value_direct"
         , "annal:field_value_type":    "annal:Richtext"
         , "annal:field_entity_type":    "test:img_type"
         , "annal:placeholder":          "(view comment field)"
         , "annal:field_placement":      "small:0,12;medium:0,6"
         , "annal:property_uri":         "rdfs:comment"
         })
     return refimg_comment_field
Exemple #18
0
    def add_field(self, field_id, field_meta):
        """
        Add a new or updated record field to the current collection

        field_id    identifier for the new field, as a string
                    with a form that is valid as URI path segment.
        field_meta  a dictionary providing additional information about
                    the field to be created.

        Returns a RecordField object for the newly created field.
        """
        log.debug("Collection.add_field %s in %s"%(field_id, self.get_id()))
        f = RecordField.create(self, field_id, field_meta)
        return f
Exemple #19
0
    def add_field(self, field_id, field_meta):
        """
        Add a new or updated record field to the current collection

        field_id    identifier for the new field, as a string
                    with a form that is valid as URI path segment.
        field_meta  a dictionary providing additional information about
                    the field to be created.

        Returns a RecordField object for the newly created field.
        """
        log.debug("Collection.add_field %s in %s"%(field_id, self.get_id()))
        f = RecordField.create(self, field_id, field_meta)
        return f
Exemple #20
0
 def test_field_comment_tooltip(self):
     """
     Test migration of field without tooltip
     """
     # Create field definition
     self.test_field = RecordField.create(self.testcoll, test_field_id,
                                          test_field_tooltip_create_values)
     # Apply migration to collection
     migrate_coll_data(self.testcoll)
     # Read field definition and check for inline field list
     field_data = self.check_entity_values(
         "_field",
         test_field_id,
         check_values=test_field_tooltip_migrated_values)
     return
 def setUp(self):
     init_annalist_test_site()
     init_annalist_test_coll()
     self.testsite = Site(TestBaseUri, TestBaseDir)
     self.testcoll = Collection(self.testsite, "testcoll")
     # Populate collection with linked record types, views and lists
     self.testsrc_type = RecordType.create(self.testcoll, "testsrc_type",
                                           testsrc_type_create_values)
     self.testtgt_type = RecordType.create(self.testcoll, "testtgt_type",
                                           testtgt_type_create_values)
     self.testsrc_view = RecordView.create(self.testcoll, "testsrc_view",
                                           testsrc_view_create_values)
     self.testtgt_view = RecordView.create(self.testcoll, "testtgt_view",
                                           testtgt_view_create_values)
     self.testsrc_list = RecordList.create(self.testcoll, "testsrc_list",
                                           testsrc_list_create_values)
     self.testtgt_list = RecordList.create(self.testcoll, "testtgt_list",
                                           testtgt_list_create_values)
     self.testtgtref_field = RecordField.create(
         self.testcoll, "testtgtref_field", testtgtref_field_create_values)
     self.no_options = [FieldChoice('', label="(no options)")]
     self.tgt_options = ([
         FieldChoice("testtgt_type/" + v,
                     label="testtgt_entity %s label" % v,
                     link=entity_url("testcoll", "testtgt_type", v))
         for v in ["testtgt1", "testtgt2"]
     ])
     # Create data records for testing:
     self.testtgt_type_info = EntityTypeInfo(self.testcoll,
                                             "testtgt_type",
                                             create_typedata=True)
     self.testsrc_type_info = EntityTypeInfo(self.testcoll,
                                             "testsrc_type",
                                             create_typedata=True)
     for tgt_id in ("testtgt1", "testtgt2"):
         self.testtgt_type_info.create_entity(
             tgt_id, testtgt_entity_create_values(tgt_id))
     for src_id, tgt_ref in (("testsrc1", "testtgt1"), ("testsrc2",
                                                        "testtgt2")):
         self.testsrc_type_info.create_entity(
             src_id, testsrc_entity_create_values(src_id, tgt_ref))
     # Login and permissions
     create_test_user(self.testcoll, "testuser", "testpassword")
     self.client = Client(HTTP_HOST=TestHost)
     loggedin = self.client.login(username="******",
                                  password="******")
     self.assertTrue(loggedin)
     return
Exemple #22
0
 def _create_rptref_field(self, label_add=None, label_delete=None):
     rptref_field = RecordField.create(
         self.testcoll, "Test_rptref_field", {
             "annal:type": "annal:Field",
             "rdfs:label": "Repeat image reference",
             "rdfs:comment": "Repeat image reference field comment",
             "annal:field_render_type": "RepeatGroupRow",
             "annal:field_value_mode": "Value_direct",
             "annal:field_value_type": "annal:Field_group",
             "annal:placeholder": "(repeat image field)",
             "annal:property_uri": "test:rpt_image",
             "annal:field_placement": "small:0,12",
             "annal:group_ref": "Test_rptref_group"
         })
     self.assertTrue(rptref_field is not None)
     return rptref_field
 def _create_ref_type_field(self, entity_type="test:testtypes"):
     ref_type_field = RecordField.create(self.testcoll, "Test_ref_type_field",
         { "annal:type":                     "annal:Field"
         , "rdfs:label":                     "Type reference"
         , "rdfs:comment":                   "Type reference field comment"
         , "annal:field_render_type":        "Enum_render_type/Enum_choice"
         , "annal:field_value_mode":         "Enum_value_mode/Value_direct"
         , "annal:field_entity_type":        "test:ref_type"
         , "annal:placeholder":              "(ref type field)"
         , "annal:property_uri":             "test:ref_type"
         , "annal:field_placement":          "small:0,12;medium:0,6"
         , "annal:field_ref_type":           "_type/testtypes"
         , "annal:field_ref_restriction":    "[test:turi] subtype %s"%entity_type
         , "annal:field_entity_type":        entity_type
         })
     self.assertTrue(ref_type_field is not None)
     return ref_type_field
Exemple #24
0
    def get_field_uri_jsonld_context(self, fid, get_field_context):
        """
        Access field description, and return field property URI and appropriate 
        property description for JSON-LD context.

        If there is no corresponding field description, returns (None, None)

        If no context should be generated for the field URI, returns (uri, None)
        """
        f = RecordField.load(self, fid, altscope="all")
        if f is None:
            return (None, None)
        # @@debugging@@
        # if fid in ["Entity_id", "List_id"]:
        #     print "@@ %s field   %r"%(fid, f)
        #     print "@@ %s context %r"%(fid, get_field_context(f))
        return (f[ANNAL.CURIE.property_uri], get_field_context(f))
    def get_field_uri_jsonld_context(self, fid, get_field_context):
        """
        Access field description, and return field property URI and appropriate 
        property description for JSON-LD context.

        If there is no corresponding field description, returns (None, None)

        If no context should be generated for the field URI, returns (uri, None)
        """
        f = RecordField.load(self, fid, altscope="all")
        if f is None:
            return (None, None)
        # @@debugging@@
        # if fid in ["Entity_id", "List_id"]:
        #     print "@@ %s field   %r"%(fid, f)
        #     print "@@ %s context %r"%(fid, get_field_context(f))
        return (f[ANNAL.CURIE.property_uri], get_field_context(f))
 def _create_testrepeatfield(self, label_add=None, label_delete=None):
     testrepeatfield = RecordField.create(self.testcoll, "testrepeatfield",
         { "annal:type":                 "annal:Field"
         , "rdfs:label":                 "Test repeat field label"
         , "rdfs:comment":               "Test repeat field comment"
         , "annal:field_render_type":    "RepeatGroupRow"
         , "annal:field_value_type":     "annal:Field_group"
         , "annal:field_entity_type":    "test:testtype"
         , "annal:placeholder":          "(test repeat field)"
         , "annal:property_uri":         "test:repeat_fields"
         , "annal:field_placement":      "small:0,12"
         , "annal:group_ref":            "testrepeatgroup"
         , "annal:repeat_label_add":     label_add
         , "annal:repeat_label_delete":  label_delete
         })
     self.assertTrue(testrepeatfield is not None)
     return testrepeatfield
 def _create_testrepeatfield(self, label_add=None, label_delete=None):
     testrepeatfield = RecordField.create(
         self.testcoll, "testrepeatfield", {
             "annal:type": "annal:Field",
             "rdfs:label": "Test repeat field label",
             "rdfs:comment": "Test repeat field comment",
             "annal:field_render_type": "RepeatGroupRow",
             "annal:field_value_type": "annal:Field_group",
             "annal:field_entity_type": "test:testtype",
             "annal:placeholder": "(test repeat field)",
             "annal:property_uri": "test:repeat_fields",
             "annal:field_placement": "small:0,12",
             "annal:group_ref": "testrepeatgroup",
             "annal:repeat_label_add": label_add,
             "annal:repeat_label_delete": label_delete
         })
     self.assertTrue(testrepeatfield is not None)
     return testrepeatfield
Exemple #28
0
 def _create_refimg_field(self, label_add=None, label_delete=None):
     refimg_field = RecordField.create(
         self.testcoll, "Test_refimg_field", {
             "annal:type": "annal:Field",
             "rdfs:label": "Image reference",
             "rdfs:comment": "Image reference field comment",
             "annal:field_render_type": "RefMultifield",
             "annal:field_value_mode": "Value_entity",
             "annal:field_value_type": "annal:Field_group",
             "annal:field_entity_type": "test:img_type",
             "annal:placeholder": "(ref image field)",
             "annal:property_uri": "test:ref_image",
             "annal:field_placement": "small:0,12;medium:0,6",
             "annal:group_ref": "Test_refimg_group",
             "annal:field_ref_type": "img_type"
         })
     self.assertTrue(refimg_field is not None)
     return refimg_field
Exemple #29
0
 def _create_ref_type_field(self, entity_type="test:testtypes"):
     ref_type_field = RecordField.create(
         self.testcoll, "Test_ref_type_field", {
             "annal:type": "annal:Field",
             "rdfs:label": "Type reference",
             "rdfs:comment": "Type reference field comment",
             "annal:field_render_type": "Enum_render_type/Enum_choice",
             "annal:field_value_mode": "Enum_value_mode/Value_direct",
             "annal:field_entity_type": "test:ref_type",
             "annal:placeholder": "(ref type field)",
             "annal:property_uri": "test:ref_type",
             "annal:field_placement": "small:0,12;medium:0,6",
             "annal:field_ref_type": "_type/testtypes",
             "annal:field_ref_restriction":
             "[test:turi] subtype %s" % entity_type,
             "annal:field_entity_type": entity_type
         })
     self.assertTrue(ref_type_field is not None)
     return ref_type_field
Exemple #30
0
    def get_field_uri_jsonld_context(self, fid, get_field_context):
        """
        Access field description, and return field property URI and appropriate 
        property description for JSON-LD context.

        Returns a triple consisting of the field property URI, the context information to be
        generated for the field, and a list of any field references contained directly within
        the field definition (as opposed to a field group reference)

        If there is no corresponding field description, returns (None, None, None)

        If no context should be generated for the field URI, returns (uri, None, field_list)

        The field list returned is 'None' if there is no contained list of fields.
        """
        f = RecordField.load(self, fid, altscope="all")
        if f is None:
            return (None, None, None)
        field_list = f.get(ANNAL.CURIE.field_fields, None)
        return (f[ANNAL.CURIE.property_uri], get_field_context(f), field_list)
Exemple #31
0
    def get_field_uri_jsonld_context(self, fid, get_field_context):
        """
        Access field description, and return field property URI and appropriate 
        property description for JSON-LD context.

        Returns a triple consisting of the field property URI, the context information to be
        generated for the field, and a list of any field references contained directly within
        the field definition (as opposed to a field group reference)

        If there is no corresponding field description, returns (None, None, None)

        If no context should be generated for the field URI, returns (uri, None, field_list)

        The field list returned is 'None' if there is no contained list of fields.
        """
        f = RecordField.load(self, fid, altscope="all")
        if f is None:
            return (None, None, None)
        field_list = f.get(ANNAL.CURIE.field_fields, None)
        return (f[ANNAL.CURIE.property_uri], get_field_context(f), field_list)
Exemple #32
0
 def test_field_fieldgroup_references(self):
     """
     Test migration of field group references in field definitions 
     """
     # Create field group
     self.test_group = RecordGroup_migration.create(
         self.testcoll, test_group_id, test_group_create_values)
     # Create field definition referencing field group
     self.test_field = RecordField.create(self.testcoll, test_field_id,
                                          test_field_group_create_values)
     # Apply migration to collection
     migrate_coll_data(self.testcoll)
     # Read field definition and check for inline field list
     field_data = self.check_entity_values(
         "_field",
         test_field_id,
         check_values=test_field_group_migrated_values)
     self.assertNotIn("annal:group_ref", field_data)
     self.check_entity_does_not_exist("_group", test_group_id)
     return
Exemple #33
0
    def get_field(self, field_id):
        """
        Retrieve identified field description

        field_id    local identifier for the field to retrieve.

        returns a RecordField object for the identified field, or None.
        """
        if not valid_id(field_id, reserved_ok=True):
            msg = "Collection %s get_field(%s) invalid id"%(self.get_id(), field_id)
            log.error(msg)
            # Construct and return a placeholder field
            ph_meta = (
                { RDFS.CURIE.label:               "(field error)"
                , ANNAL.CURIE.field_render_type:  "_enum_render_type/Placeholder"
                , ANNAL.CURIE.field_value_mode:   "_enum_value_mode/Value_direct"
                , ANNAL.CURIE.field_placement:    "small:0,12"
                , ANNAL.CURIE.placeholder:        
                    "(Invalid field id: '%s')"%(field_id,)
                })
            f = RecordField._child_init(self, "_placeholder")
            f.set_values(ph_meta)
            return f
        return self.cache_get_field(field_id)
Exemple #34
0
 def create_subproperty_field_view_entity(self):
     # Create test field using superproperty
     self.test_sup_field = RecordField.create(
         self.testcoll, "Test_sup_field", {
             ANNAL.CURIE.type: "annal:Field",
             RDFS.CURIE.label: "Field using superproperty URI",
             RDFS.CURIE.comment: "Field using superproperty URI",
             ANNAL.CURIE.field_render_type: "_enum_render_type/Text",
             ANNAL.CURIE.field_value_mode: "_enum_value_mode/Value_direct",
             ANNAL.CURIE.field_entity_type: "test:testtype",
             ANNAL.CURIE.placeholder: "(Test_sup_field)",
             ANNAL.CURIE.property_uri: "test:superprop_uri",
             ANNAL.CURIE.field_placement: "small:0,12;medium:0,6"
         })
     self.assertTrue(self.test_sup_field is not None)
     # Create test field using subproperty and declaring superproperty
     self.test_sub_field = RecordField.create(
         self.testcoll, "Test_sub_field", {
             ANNAL.CURIE.type: "annal:Field",
             RDFS.CURIE.label: "Field using superproperty URI",
             RDFS.CURIE.comment: "Field using superproperty URI",
             ANNAL.CURIE.field_render_type: "_enum_render_type/Text",
             ANNAL.CURIE.field_value_mode: "_enum_value_mode/Value_direct",
             ANNAL.CURIE.field_entity_type: "test:testtype",
             ANNAL.CURIE.placeholder: "(Test_sub_field)",
             ANNAL.CURIE.property_uri: "test:subprop_uri",
             ANNAL.CURIE.superproperty_uri: [{
                 "@id": "test:superprop_uri"
             }],
             ANNAL.CURIE.field_placement: "small:0,12;medium:0,6"
         })
     self.assertTrue(self.test_sub_field is not None)
     # Create test view using superproperty
     self.test_view = RecordView.create(
         self.testcoll, "testview", {
             ANNAL.CURIE.type:
             "annal:View",
             ANNAL.CURIE.uri:
             "test:view",
             RDFS.CURIE.label:
             "Test view label",
             RDFS.CURIE.comment:
             "Test view comment",
             ANNAL.CURIE.view_entity_type:
             "test:testtype",
             ANNAL.CURIE.view_fields:
             [{
                 ANNAL.CURIE.field_id: layout.FIELD_TYPEID + "/Entity_id",
                 ANNAL.CURIE.field_placement: "small:0,12;medium:0,6"
             }, {
                 ANNAL.CURIE.field_id:
                 layout.FIELD_TYPEID + "/Test_sup_field",
                 ANNAL.CURIE.field_placement: "small:0,12;medium:0,6"
             }]
         })
     self.assertTrue(self.test_view is not None)
     # Create test entity using subproperty
     self.testentity_data = EntityData.create(
         self.testdata, "testentity",
         entitydata_create_values(
             "testentity",
             type_id="testtype",
             type_uri="test:testtype",
             extra_fields={"test:subprop_uri": "Test field value"}))
     self.assertTrue(self.testentity_data is not None)
     return
Exemple #35
0
    def setUp(self):
        self.filepath  = "%s/testdatafile.md"%TestBaseDir
        self.fileuri   = "file://"+self.filepath
        self.imagepath = "%s/test-image.jpg"%TestBaseDir
        self.imageuri  = "file://"+self.imagepath
        init_annalist_test_site()
        init_annalist_test_coll()
        self.testsite  = Site(TestBaseUri, TestBaseDir)
        self.testcoll  = Collection(self.testsite, "testcoll")
        # Populate collection with linked record types, views and lists

        # Types
        self.test_upl_type = RecordType.create(
            self.testcoll, "testupltype", test_upload_type_create_values
            )
        self.test_ref_type = RecordType.create(
            self.testcoll, "testreftype", test_reference_type_create_values
            )
        self.test_image_type = RecordType.create(
            self.testcoll, "testimgtype", test_image_type_create_values
            )

        # Views
        self.test_upl_file_view = RecordView.create(
            self.testcoll, "testuplfileview", test_upload_file_view_create_values
            )
        self.test_upl_image_view = RecordView.create(
            self.testcoll, "testuplimageview", test_upload_image_view_create_values
            )
        self.test_ref_file_view = RecordView.create(
            self.testcoll, "testrefview", test_reference_view_create_values
            )
        self.test_ref_image_view = RecordView.create(
            self.testcoll, "testimgrefview", test_image_ref_view_create_values
            )
        self.test_image_view = RecordView.create(
            self.testcoll, "testimgview", test_image_view_create_values
            )

        # Fields
        self.test_upl_file_field = RecordField.create(
            self.testcoll, "Test_upload_file", test_upload_file_field_create_values
            )
        self.test_upl_image_field = RecordField.create(
            self.testcoll, "Test_upload_image", test_upload_image_field_create_values
            )
        self.test_ref_file_field = RecordField.create(
            self.testcoll, "Test_reference", test_reference_field_create_values
            )
        self.test_ref_image_field = RecordField.create(
            self.testcoll, "Test_image_ref", test_image_ref_field_create_values
            )
        self.test_image_field = RecordField.create(
            self.testcoll, "Test_image", test_image_field_create_values
            )

        # Create data records for testing import and references:
        test_entity_ids = ("test1", "test2")
        test_entity_ids = ("test1",)
        self.test_upl_type_info = EntityTypeInfo(
            self.testcoll, "testupltype", create_typedata=True
            )
        for entity_id in test_entity_ids:
            self.test_upl_type_info.create_entity(
                entity_id, test_imp_entity_create_values(entity_id)
                )
        self.test_ref_type_info = EntityTypeInfo(
            self.testcoll, "testreftype", create_typedata=True
            )
        for entity_id in test_entity_ids:
            self.test_ref_type_info.create_entity(
                entity_id, test_ref_entity_create_values(entity_id)
                )
        self.test_img_type_info = EntityTypeInfo(
            self.testcoll, "testimgtype", create_typedata=True
            )
        for entity_id in test_entity_ids:
            self.test_img_type_info.create_entity(
                entity_id, test_img_entity_create_values(entity_id)
                )
        # Login and permissions
        create_test_user(self.testcoll, "testuser", "testpassword")
        self.client = Client(HTTP_HOST=TestHost)
        loggedin = self.client.login(username="******", password="******")
        self.assertTrue(loggedin)
        return
def coll_field(coll, field_id):
    """
    Return identified field in collection, or None
    """
    return RecordField.load(coll, field_id, altscope="all")
class CollectionFieldCacheTest(AnnalistTestCase):
    """
    Tests for collection field and superproperty cache classes.
    """

    def setUp(self):
        init_annalist_test_site()
        self.testsite   = Site(TestBaseUri, TestBaseDir)
        self.testcoll   = Collection(self.testsite, "testcoll")
        self.testcoll1  = Collection(self.testsite, "testcoll1")
        self.testcoll2  = Collection(self.testsite, "testcoll2")
        self.fieldcache = CollectionFieldCache()
        self.field1     = RecordField(self.testcoll1, "field1")
        self.field1.set_values(
            recordfield_create_values(field_id="field1", property_uri="test:field1", 
                superproperty_uris=[]
                )
            )
        self.field11   = RecordField(self.testcoll1, "field11")
        self.field11.set_values(
            recordfield_create_values(field_id="field11", property_uri="test:field11", 
                superproperty_uris=["test:field1"]
                )
            )
        self.field111  = RecordField(self.testcoll1, "field111")
        self.field111.set_values(
            recordfield_create_values(field_id="field111", property_uri="test:field111", 
                superproperty_uris=["test:field11"]
                )
            )
        self.field2    = RecordField(self.testcoll1, "field2")
        self.field2.set_values(
            recordfield_create_values(field_id="field2", property_uri="test:field2", 
                superproperty_uris=[]
                )
            )
        return

    def create_field_record(self, coll, field_entity):
        return RecordField.create(coll, field_entity.get_id(), field_entity.get_values())

    def create_test_field_entities(self):
        # Create records in collection data
        self.create_field_record(self.testcoll1, self.field1)
        self.create_field_record(self.testcoll1, self.field11)
        self.create_field_record(self.testcoll1, self.field111)
        self.create_field_record(self.testcoll1, self.field2)
        # Add all records to cache
        self.fieldcache.set_field(self.testcoll1, self.field1)
        self.fieldcache.set_field(self.testcoll1, self.field11)
        self.fieldcache.set_field(self.testcoll1, self.field111)
        self.fieldcache.set_field(self.testcoll1, self.field2)
        # Check cache content
        self.expect_site_field_ids = get_site_fields()
        self.expect_coll_field_ids = (
            { "field1", "field11", "field111", "field2" }
            )
        self.expect_all_field_ids = set.union(self.expect_site_field_ids, self.expect_coll_field_ids)
        retrieve_field_ids = set(f.get_id() for f in self.fieldcache.get_all_fields(self.testcoll1))
        self.assertEqual(retrieve_field_ids, self.expect_coll_field_ids)
        return

    def tearDown(self):
        resetSitedata(scope="collections")
        return

    def get_coll_field(self, coll, field_id):
        return self.fieldcache.get_field(coll, field_id)

    def get_coll_field_uri(self, coll, field_id):
        return self.get_coll_field(coll, field_id).get_property_uri()

    def get_coll_uri_field(self, coll, property_uri):
        return self.fieldcache.get_field_from_uri(coll, property_uri)

    def get_coll_uri_id(self, coll, property_uri):
        return self.get_coll_uri_field(coll, property_uri).get_id()

    def get_coll_property_uris(self, coll):
        return { f.get_property_uri() for f in self.fieldcache.get_all_fields(coll) }

    # Start of tests

    def test_empty_cache(self):
        self.assertEqual(set(self.fieldcache.get_all_fields(self.testcoll1)), set())
        self.assertEqual(set(self.fieldcache.get_all_fields(self.testcoll2)), set())
        return

    def test_singleton_cache(self):
        self.assertEqual(self.get_coll_property_uris(self.testcoll1), set())
        self.create_field_record(self.testcoll1, self.field1)
        # NOTE: the 'set_field' call also causes cache initialization of all fields, 
        # including the created field record which is discovered on disk, and the subsequent 
        # set_field call returns 'False'.
        self.assertFalse(self.fieldcache.set_field(self.testcoll1, self.field1))
        self.assertFalse(self.fieldcache.set_field(self.testcoll1, self.field1))
        self.assertEqual(self.get_coll_field_uri(self.testcoll1, "field1"),      "test:field1")
        self.assertEqual(self.get_coll_field(self.testcoll1,     "field2"),      None)
        self.assertEqual(self.get_coll_uri_id(self.testcoll1,    "test:field1"), "field1")
        self.assertEqual(self.get_coll_uri_field(self.testcoll1, "test:field2"), None)
        self.assertEqual(self.get_coll_property_uris(self.testcoll1), {"test:field1"})
        self.assertEqual(self.get_coll_property_uris(self.testcoll2), set())
        return

    def test_empty_cache_2(self):
        self.fieldcache.set_field(self.testcoll1, self.field1)
        self.assertIsNotNone(self.fieldcache.remove_field(self.testcoll1, "field1"))
        self.assertIsNone(self.fieldcache.remove_field(self.testcoll1, "field1"))
        self.assertEqual(list(self.fieldcache.get_all_fields(self.testcoll1)), [])
        self.assertEqual(list(self.fieldcache.get_all_fields(self.testcoll2)), [])
        return

    def test_flush_cache(self):
        self.fieldcache.set_field(self.testcoll1, self.field1)
        self.assertTrue(self.fieldcache.flush_cache(self.testcoll1))
        self.assertIsNone(self.fieldcache.remove_field(self.testcoll1, "field1"))
        self.assertEqual(list(self.fieldcache.get_all_fields(self.testcoll1)), [])
        self.assertEqual(list(self.fieldcache.get_all_fields(self.testcoll2)), [])
        self.assertTrue(self.fieldcache.flush_cache(self.testcoll1))
        self.assertFalse(self.fieldcache.flush_cache(self.testcoll1))
        return

    def test_get_fields_by_uri(self):
        self.create_test_field_entities()
        self.assertEqual(self.fieldcache.get_field_from_uri(self.testcoll1, "test:field1").get_id(),   "field1")
        self.assertEqual(self.fieldcache.get_field_from_uri(self.testcoll1, "test:field11").get_id(),  "field11")
        self.assertEqual(self.fieldcache.get_field_from_uri(self.testcoll1, "test:field111").get_id(), "field111")
        self.assertEqual(self.fieldcache.get_field_from_uri(self.testcoll1, "test:field2").get_id(),   "field2")
        return

    def test_get_all_fields_scope_coll(self):
        self.create_test_field_entities()
        field_ids = set(f.get_id() for f in self.fieldcache.get_all_fields(self.testcoll1))
        self.assertEqual(field_ids, self.expect_coll_field_ids)
        field_ids = set(f.get_id() for f in self.fieldcache.get_all_fields(self.testcoll1))
        self.assertEqual(field_ids, self.expect_coll_field_ids)
        return

    def test_get_all_fields_scope_all(self):
        self.create_test_field_entities()
        field_ids = set(
            f.get_id() 
            for f in self.fieldcache.get_all_fields(self.testcoll1, altscope="all")
            )
        self.assertEqual(field_ids, self.expect_all_field_ids)
        return

    def test_get_superproperty_fields(self):
        self.create_test_field_entities()
        def get_superproperty_uris(property_uri):
            sf_entities = self.fieldcache.get_superproperty_fields(self.testcoll1, property_uri)
            sp_uris     = [ sf.get_property_uri() for sf in sf_entities ]
            return set(sp_uris)
        self.assertEqual(get_superproperty_uris("test:field1"),   set())
        self.assertEqual(get_superproperty_uris("test:field11"),  {"test:field1"})
        self.assertEqual(get_superproperty_uris("test:field111"), {"test:field1", "test:field11"})
        self.assertEqual(get_superproperty_uris("test:field2"),   set({}))
        return

    def test_get_subproperty_fields(self):
        self.create_test_field_entities()
        def get_subproperty_uris(property_uri):
            sf_entities = self.fieldcache.get_subproperty_fields(self.testcoll1, property_uri)
            sp_uris     = [ sf.get_property_uri() for sf in sf_entities ]
            return set(sp_uris)
        self.assertEqual(get_subproperty_uris("test:field1"),   {"test:field11", "test:field111"})
        self.assertEqual(get_subproperty_uris("test:field11"),  {"test:field111"})
        self.assertEqual(get_subproperty_uris("test:field111"), set())
        self.assertEqual(get_subproperty_uris("test:field2"),   set())
        return

    def test_update_superproperty(self):
        self.create_test_field_entities()
        def get_superproperty_uris(property_uri):
            sf_entities = self.fieldcache.get_superproperty_fields(self.testcoll1, property_uri)
            sp_uris     = [ sf.get_property_uri() for sf in sf_entities ]
            return set(sp_uris)
        self.assertEqual(get_superproperty_uris("test:field1"),   set())
        self.assertEqual(get_superproperty_uris("test:field11"),  {"test:field1"})
        self.assertEqual(get_superproperty_uris("test:field111"), {"test:field1", "test:field11"})
        self.assertEqual(get_superproperty_uris("test:field2"),   set())
        # Update super/sub-type
        self.fieldcache.remove_field(self.testcoll1, "field11")
        self.fieldcache.set_field(self.testcoll1, self.field11)
        # Re-check supertypes
        self.assertEqual(get_superproperty_uris("test:field1"),   set())
        self.assertEqual(get_superproperty_uris("test:field11"),  {"test:field1"})
        self.assertEqual(get_superproperty_uris("test:field111"), {"test:field1", "test:field11"})
        self.assertEqual(get_superproperty_uris("test:field2"),   set())
        return

    def test_update_subproperty(self):
        self.create_test_field_entities()
        def get_subproperty_uris(property_uri):
            sf_entities = self.fieldcache.get_subproperty_fields(self.testcoll1, property_uri)
            sp_uris     = [ sf.get_property_uri() for sf in sf_entities ]
            return set(sp_uris)
        self.assertEqual(get_subproperty_uris("test:field1"),   {"test:field11", "test:field111"})
        self.assertEqual(get_subproperty_uris("test:field11"),  {"test:field111"})
        self.assertEqual(get_subproperty_uris("test:field111"), set())
        self.assertEqual(get_subproperty_uris("test:field2"),   set())
        # Update super/sub-property
        self.fieldcache.remove_field(self.testcoll1, "field11")
        self.fieldcache.set_field(self.testcoll1, self.field11)
        # Re-check subproperties
        self.assertEqual(get_subproperty_uris("test:field1"),   {"test:field11", "test:field111"})
        self.assertEqual(get_subproperty_uris("test:field11"),  {"test:field111"})
        self.assertEqual(get_subproperty_uris("test:field111"), set())
        self.assertEqual(get_subproperty_uris("test:field2"),   set())
        return
Exemple #38
0
 def create_field_record(self, coll, field_entity):
     return RecordField.create(coll, field_entity.get_id(),
                               field_entity.get_values())
 def create_subproperty_list_field_view_entity(self):
     # Create list field using superproperty
     self.test_sup_list = RecordField.create(self.testcoll, "Test_sup_list",
         { ANNAL.CURIE.type:                 "annal:Field"
         , RDFS.CURIE.label:                 "List using superproperty URI"
         , RDFS.CURIE.comment:               "List using superproperty URI"
         , ANNAL.CURIE.field_render_type:    "_enum_render_type/Group_Seq_Row"
         , ANNAL.CURIE.field_value_mode:     "_enum_value_mode/Value_direct"
         , ANNAL.CURIE.field_value_type:     "annal:Test_sup_list"
         , ANNAL.CURIE.field_entity_type:    "test:testtype"
         , ANNAL.CURIE.placeholder:          "(Test_sup_list)"
         , ANNAL.CURIE.property_uri:         "test:superprop_list_uri"
         , ANNAL.CURIE.field_placement:      "small:0,12"
         , ANNAL.CURIE.field_fields:
           [ { ANNAL.CURIE.field_id:         "_field/Test_sup_field"
             , ANNAL.CURIE.field_placement:  "small:0,12"
             }
           ]
         , ANNAL.CURIE.repeat_label_add:     "Add sup entity"
         , ANNAL.CURIE.repeat_label_delete:  "Remove sup entity"
         })
     self.assertTrue(self.test_sup_list is not None)
     # Create list field using subproperty and declaring superproperty
     self.test_sub_list = RecordField.create(self.testcoll, "Test_sub_list",
         { ANNAL.CURIE.type:                 "annal:Field"
         , RDFS.CURIE.label:                 "List using superproperty URI"
         , RDFS.CURIE.comment:               "List using superproperty URI"
         , ANNAL.CURIE.field_render_type:    "_enum_render_type/Group_Seq_Row"
         , ANNAL.CURIE.field_value_mode:     "_enum_value_mode/Value_direct"
         , ANNAL.CURIE.field_value_type:     "annal:Test_sub_list"
         , ANNAL.CURIE.field_entity_type:    "test:testtype"
         , ANNAL.CURIE.placeholder:          "(Test_sub_list)"
         , ANNAL.CURIE.property_uri:         "test:subprop_list_uri"
         , ANNAL.CURIE.superproperty_uri:    [{"@id": "test:superprop_list_uri"}]
         , ANNAL.CURIE.field_placement:      "small:0,12"
         , ANNAL.CURIE.field_fields:
           [ { ANNAL.CURIE.field_id:         "_field/Test_sub_field"
             , ANNAL.CURIE.field_placement:  "small:0,12"
             }
           ]
         , ANNAL.CURIE.repeat_label_add:     "Add sub entity"
         , ANNAL.CURIE.repeat_label_delete:  "Remove sub entity"
         })
     self.assertTrue(self.test_sub_list is not None)
     # Create test view using superproperty
     self.test_view = RecordView.create(self.testcoll, "testlistview",
         { ANNAL.CURIE.type:             "annal:View"
         , ANNAL.CURIE.uri:              "test:listview"
         , RDFS.CURIE.label:             "Test listview label"
         , RDFS.CURIE.comment:           "Test listview comment"
         , ANNAL.CURIE.view_entity_type: "test:testtype"
         , ANNAL.CURIE.view_fields:
           [ { ANNAL.CURIE.field_id:         layout.FIELD_TYPEID+"/Entity_id"
             , ANNAL.CURIE.field_placement:  "small:0,12;medium:0,6"
             }
           , { ANNAL.CURIE.field_id:         layout.FIELD_TYPEID+"/Test_sup_list"
             , ANNAL.CURIE.field_placement:  "small:0,12;medium:0,6"
             }
           ]
         })
     self.assertTrue(self.test_view is not None)
     # Create test entity using list and item subproperty URIs
     self.testlistentity_data = EntityData.create(self.testdata, "testlistentity", 
         entitydata_create_values(
             "testlistentity", type_id="testtype",
             type_uri="test:testtype",
             extra_fields=
               { "test:subprop_list_uri":
                 [ { "test:subprop_uri": "Test field 1 value"}
                 , { "test:subprop_uri": "Test field 2 value"}
                 ]
               }
             )
         )
     self.assertTrue(self.testlistentity_data is not None)
     return
def coll_type(coll, type_id):
    """
    Return identified type in collection, or None
    """
    return RecordField.load(coll, field_id, altscope="all")
Exemple #41
0
class CollectionFieldCacheTest(AnnalistTestCase):
    """
    Tests for collection field and superproperty cache classes.
    """
    def setUp(self):
        init_annalist_test_site()
        self.testsite = Site(TestBaseUri, TestBaseDir)
        self.testcoll = Collection(self.testsite, "testcoll")
        self.testcoll1 = Collection(self.testsite, "testcoll1")
        self.testcoll2 = Collection(self.testsite, "testcoll2")
        self.fieldcache = CollectionFieldCache()
        self.field1 = RecordField(self.testcoll1, "field1")
        self.field1.set_values(
            recordfield_create_values(field_id="field1",
                                      property_uri="test:field1",
                                      superproperty_uris=[]))
        self.field11 = RecordField(self.testcoll1, "field11")
        self.field11.set_values(
            recordfield_create_values(field_id="field11",
                                      property_uri="test:field11",
                                      superproperty_uris=["test:field1"]))
        self.field111 = RecordField(self.testcoll1, "field111")
        self.field111.set_values(
            recordfield_create_values(field_id="field111",
                                      property_uri="test:field111",
                                      superproperty_uris=["test:field11"]))
        self.field2 = RecordField(self.testcoll1, "field2")
        self.field2.set_values(
            recordfield_create_values(field_id="field2",
                                      property_uri="test:field2",
                                      superproperty_uris=[]))
        return

    def create_field_record(self, coll, field_entity):
        return RecordField.create(coll, field_entity.get_id(),
                                  field_entity.get_values())

    def create_test_field_entities(self):
        # Create records in collection data
        self.create_field_record(self.testcoll1, self.field1)
        self.create_field_record(self.testcoll1, self.field11)
        self.create_field_record(self.testcoll1, self.field111)
        self.create_field_record(self.testcoll1, self.field2)
        # Add all records to cache
        self.fieldcache.set_field(self.testcoll1, self.field1)
        self.fieldcache.set_field(self.testcoll1, self.field11)
        self.fieldcache.set_field(self.testcoll1, self.field111)
        self.fieldcache.set_field(self.testcoll1, self.field2)
        # Check cache content
        self.expect_site_field_ids = get_site_fields()
        self.expect_coll_field_ids = ({
            "field1", "field11", "field111", "field2"
        })
        self.expect_all_field_ids = set.union(self.expect_site_field_ids,
                                              self.expect_coll_field_ids)
        retrieve_field_ids = set(
            f.get_id() for f in self.fieldcache.get_all_fields(self.testcoll1))
        self.assertEqual(retrieve_field_ids, self.expect_coll_field_ids)
        return

    def tearDown(self):
        resetSitedata(scope="collections")
        return

    def get_coll_field(self, coll, field_id):
        return self.fieldcache.get_field(coll, field_id)

    def get_coll_field_uri(self, coll, field_id):
        return self.get_coll_field(coll, field_id).get_property_uri()

    def get_coll_uri_field(self, coll, property_uri):
        return self.fieldcache.get_field_from_uri(coll, property_uri)

    def get_coll_uri_id(self, coll, property_uri):
        return self.get_coll_uri_field(coll, property_uri).get_id()

    def get_coll_property_uris(self, coll):
        return {
            f.get_property_uri()
            for f in self.fieldcache.get_all_fields(coll)
        }

    # Start of tests

    def test_empty_cache(self):
        self.assertEqual(set(self.fieldcache.get_all_fields(self.testcoll1)),
                         set())
        self.assertEqual(set(self.fieldcache.get_all_fields(self.testcoll2)),
                         set())
        return

    def test_singleton_cache(self):
        self.assertEqual(self.get_coll_property_uris(self.testcoll1), set())
        self.create_field_record(self.testcoll1, self.field1)
        # NOTE: the 'set_field' call also causes cache initialization of all fields,
        # including the created field record which is discovered on disk, and the subsequent
        # set_field call returns 'False'.
        self.assertFalse(self.fieldcache.set_field(self.testcoll1,
                                                   self.field1))
        self.assertFalse(self.fieldcache.set_field(self.testcoll1,
                                                   self.field1))
        self.assertEqual(self.get_coll_field_uri(self.testcoll1, "field1"),
                         "test:field1")
        self.assertEqual(self.get_coll_field(self.testcoll1, "field2"), None)
        self.assertEqual(self.get_coll_uri_id(self.testcoll1, "test:field1"),
                         "field1")
        self.assertEqual(
            self.get_coll_uri_field(self.testcoll1, "test:field2"), None)
        self.assertEqual(self.get_coll_property_uris(self.testcoll1),
                         {"test:field1"})
        self.assertEqual(self.get_coll_property_uris(self.testcoll2), set())
        return

    def test_empty_cache_2(self):
        self.fieldcache.set_field(self.testcoll1, self.field1)
        self.assertIsNotNone(
            self.fieldcache.remove_field(self.testcoll1, "field1"))
        self.assertIsNone(
            self.fieldcache.remove_field(self.testcoll1, "field1"))
        self.assertEqual(list(self.fieldcache.get_all_fields(self.testcoll1)),
                         [])
        self.assertEqual(list(self.fieldcache.get_all_fields(self.testcoll2)),
                         [])
        return

    def test_flush_cache(self):
        self.fieldcache.set_field(self.testcoll1, self.field1)
        self.assertTrue(self.fieldcache.flush_cache(self.testcoll1))
        self.assertIsNone(
            self.fieldcache.remove_field(self.testcoll1, "field1"))
        self.assertEqual(list(self.fieldcache.get_all_fields(self.testcoll1)),
                         [])
        self.assertEqual(list(self.fieldcache.get_all_fields(self.testcoll2)),
                         [])
        self.assertTrue(self.fieldcache.flush_cache(self.testcoll1))
        self.assertFalse(self.fieldcache.flush_cache(self.testcoll1))
        return

    def test_get_fields_by_uri(self):
        self.create_test_field_entities()
        self.assertEqual(
            self.fieldcache.get_field_from_uri(self.testcoll1,
                                               "test:field1").get_id(),
            "field1")
        self.assertEqual(
            self.fieldcache.get_field_from_uri(self.testcoll1,
                                               "test:field11").get_id(),
            "field11")
        self.assertEqual(
            self.fieldcache.get_field_from_uri(self.testcoll1,
                                               "test:field111").get_id(),
            "field111")
        self.assertEqual(
            self.fieldcache.get_field_from_uri(self.testcoll1,
                                               "test:field2").get_id(),
            "field2")
        return

    def test_get_all_fields_scope_coll(self):
        self.create_test_field_entities()
        field_ids = set(
            f.get_id() for f in self.fieldcache.get_all_fields(self.testcoll1))
        self.assertEqual(field_ids, self.expect_coll_field_ids)
        field_ids = set(
            f.get_id() for f in self.fieldcache.get_all_fields(self.testcoll1))
        self.assertEqual(field_ids, self.expect_coll_field_ids)
        return

    def test_get_all_fields_scope_all(self):
        self.create_test_field_entities()
        field_ids = set(f.get_id() for f in self.fieldcache.get_all_fields(
            self.testcoll1, altscope="all"))
        self.assertEqual(field_ids, self.expect_all_field_ids)
        return

    def test_get_superproperty_fields(self):
        self.create_test_field_entities()

        def get_superproperty_uris(property_uri):
            sf_entities = self.fieldcache.get_superproperty_fields(
                self.testcoll1, property_uri)
            sp_uris = [sf.get_property_uri() for sf in sf_entities]
            return set(sp_uris)

        self.assertEqual(get_superproperty_uris("test:field1"), set())
        self.assertEqual(get_superproperty_uris("test:field11"),
                         {"test:field1"})
        self.assertEqual(get_superproperty_uris("test:field111"),
                         {"test:field1", "test:field11"})
        self.assertEqual(get_superproperty_uris("test:field2"), set({}))
        return

    def test_get_subproperty_fields(self):
        self.create_test_field_entities()

        def get_subproperty_uris(property_uri):
            sf_entities = self.fieldcache.get_subproperty_fields(
                self.testcoll1, property_uri)
            sp_uris = [sf.get_property_uri() for sf in sf_entities]
            return set(sp_uris)

        self.assertEqual(get_subproperty_uris("test:field1"),
                         {"test:field11", "test:field111"})
        self.assertEqual(get_subproperty_uris("test:field11"),
                         {"test:field111"})
        self.assertEqual(get_subproperty_uris("test:field111"), set())
        self.assertEqual(get_subproperty_uris("test:field2"), set())
        return

    def test_update_superproperty(self):
        self.create_test_field_entities()

        def get_superproperty_uris(property_uri):
            sf_entities = self.fieldcache.get_superproperty_fields(
                self.testcoll1, property_uri)
            sp_uris = [sf.get_property_uri() for sf in sf_entities]
            return set(sp_uris)

        self.assertEqual(get_superproperty_uris("test:field1"), set())
        self.assertEqual(get_superproperty_uris("test:field11"),
                         {"test:field1"})
        self.assertEqual(get_superproperty_uris("test:field111"),
                         {"test:field1", "test:field11"})
        self.assertEqual(get_superproperty_uris("test:field2"), set())
        # Update super/sub-type
        self.fieldcache.remove_field(self.testcoll1, "field11")
        self.fieldcache.set_field(self.testcoll1, self.field11)
        # Re-check supertypes
        self.assertEqual(get_superproperty_uris("test:field1"), set())
        self.assertEqual(get_superproperty_uris("test:field11"),
                         {"test:field1"})
        self.assertEqual(get_superproperty_uris("test:field111"),
                         {"test:field1", "test:field11"})
        self.assertEqual(get_superproperty_uris("test:field2"), set())
        return

    def test_update_subproperty(self):
        self.create_test_field_entities()

        def get_subproperty_uris(property_uri):
            sf_entities = self.fieldcache.get_subproperty_fields(
                self.testcoll1, property_uri)
            sp_uris = [sf.get_property_uri() for sf in sf_entities]
            return set(sp_uris)

        self.assertEqual(get_subproperty_uris("test:field1"),
                         {"test:field11", "test:field111"})
        self.assertEqual(get_subproperty_uris("test:field11"),
                         {"test:field111"})
        self.assertEqual(get_subproperty_uris("test:field111"), set())
        self.assertEqual(get_subproperty_uris("test:field2"), set())
        # Update super/sub-property
        self.fieldcache.remove_field(self.testcoll1, "field11")
        self.fieldcache.set_field(self.testcoll1, self.field11)
        # Re-check subproperties
        self.assertEqual(get_subproperty_uris("test:field1"),
                         {"test:field11", "test:field111"})
        self.assertEqual(get_subproperty_uris("test:field11"),
                         {"test:field111"})
        self.assertEqual(get_subproperty_uris("test:field111"), set())
        self.assertEqual(get_subproperty_uris("test:field2"), set())
        return
 def create_field_record(self, coll, field_entity):
     return RecordField.create(coll, field_entity.get_id(), field_entity.get_values())
    def setUp(self):
        self.filepath = "%s/testdatafile.md" % TestBaseDir
        self.fileuri = "file://" + self.filepath
        self.imagepath = "%s/test-image.jpg" % TestBaseDir
        self.imageuri = "file://" + self.imagepath
        init_annalist_test_site()
        init_annalist_test_coll()
        self.testsite = Site(TestBaseUri, TestBaseDir)
        self.testcoll = Collection(self.testsite, "testcoll")
        # Populate collection with linked record types, views and lists

        # Types
        self.test_upl_type = RecordType.create(self.testcoll, "testupltype",
                                               test_upload_type_create_values)
        self.test_ref_type = RecordType.create(
            self.testcoll, "testreftype", test_reference_type_create_values)
        self.test_image_type = RecordType.create(
            self.testcoll, "testimgtype", test_image_type_create_values)

        # Views
        self.test_upl_file_view = RecordView.create(
            self.testcoll, "testuplfileview",
            test_upload_file_view_create_values)
        self.test_upl_image_view = RecordView.create(
            self.testcoll, "testuplimageview",
            test_upload_image_view_create_values)
        self.test_ref_file_view = RecordView.create(
            self.testcoll, "testrefview", test_reference_view_create_values)
        self.test_ref_image_view = RecordView.create(
            self.testcoll, "testimgrefview", test_image_ref_view_create_values)
        self.test_image_view = RecordView.create(
            self.testcoll, "testimgview", test_image_view_create_values)

        # Fields
        self.test_upl_file_field = RecordField.create(
            self.testcoll, "Test_upload_file",
            test_upload_file_field_create_values)
        self.test_upl_image_field = RecordField.create(
            self.testcoll, "Test_upload_image",
            test_upload_image_field_create_values)
        self.test_ref_file_field = RecordField.create(
            self.testcoll, "Test_reference",
            test_reference_field_create_values)
        self.test_ref_image_field = RecordField.create(
            self.testcoll, "Test_image_ref",
            test_image_ref_field_create_values)
        self.test_image_field = RecordField.create(
            self.testcoll, "Test_image", test_image_field_create_values)

        # Create data records for testing import and references:
        test_entity_ids = ("test1", "test2")
        test_entity_ids = ("test1", )
        self.test_upl_type_info = EntityTypeInfo(self.testcoll,
                                                 "testupltype",
                                                 create_typedata=True)
        for entity_id in test_entity_ids:
            self.test_upl_type_info.create_entity(
                entity_id, test_imp_entity_create_values(entity_id))
        self.test_ref_type_info = EntityTypeInfo(self.testcoll,
                                                 "testreftype",
                                                 create_typedata=True)
        for entity_id in test_entity_ids:
            self.test_ref_type_info.create_entity(
                entity_id, test_ref_entity_create_values(entity_id))
        self.test_img_type_info = EntityTypeInfo(self.testcoll,
                                                 "testimgtype",
                                                 create_typedata=True)
        for entity_id in test_entity_ids:
            self.test_img_type_info.create_entity(
                entity_id, test_img_entity_create_values(entity_id))
        # Login and permissions
        create_test_user(self.testcoll, "testuser", "testpassword")
        self.client = Client(HTTP_HOST=TestHost)
        loggedin = self.client.login(username="******",
                                     password="******")
        self.assertTrue(loggedin)
        return
Exemple #44
0
 def create_subproperty_list_field_view_entity(self):
     # Create list field using superproperty
     self.test_sup_list = RecordField.create(
         self.testcoll, "Test_sup_list", {
             ANNAL.CURIE.type:
             "annal:Field",
             RDFS.CURIE.label:
             "List using superproperty URI",
             RDFS.CURIE.comment:
             "List using superproperty URI",
             ANNAL.CURIE.field_render_type:
             "_enum_render_type/Group_Seq_Row",
             ANNAL.CURIE.field_value_mode:
             "_enum_value_mode/Value_direct",
             ANNAL.CURIE.field_value_type:
             "annal:Test_sup_list",
             ANNAL.CURIE.field_entity_type:
             "test:testtype",
             ANNAL.CURIE.placeholder:
             "(Test_sup_list)",
             ANNAL.CURIE.property_uri:
             "test:superprop_list_uri",
             ANNAL.CURIE.field_placement:
             "small:0,12",
             ANNAL.CURIE.field_fields:
             [{
                 ANNAL.CURIE.field_id: "_field/Test_sup_field",
                 ANNAL.CURIE.field_placement: "small:0,12"
             }],
             ANNAL.CURIE.repeat_label_add:
             "Add sup entity",
             ANNAL.CURIE.repeat_label_delete:
             "Remove sup entity"
         })
     self.assertTrue(self.test_sup_list is not None)
     # Create list field using subproperty and declaring superproperty
     self.test_sub_list = RecordField.create(
         self.testcoll, "Test_sub_list", {
             ANNAL.CURIE.type:
             "annal:Field",
             RDFS.CURIE.label:
             "List using superproperty URI",
             RDFS.CURIE.comment:
             "List using superproperty URI",
             ANNAL.CURIE.field_render_type:
             "_enum_render_type/Group_Seq_Row",
             ANNAL.CURIE.field_value_mode:
             "_enum_value_mode/Value_direct",
             ANNAL.CURIE.field_value_type:
             "annal:Test_sub_list",
             ANNAL.CURIE.field_entity_type:
             "test:testtype",
             ANNAL.CURIE.placeholder:
             "(Test_sub_list)",
             ANNAL.CURIE.property_uri:
             "test:subprop_list_uri",
             ANNAL.CURIE.superproperty_uri: [{
                 "@id":
                 "test:superprop_list_uri"
             }],
             ANNAL.CURIE.field_placement:
             "small:0,12",
             ANNAL.CURIE.field_fields:
             [{
                 ANNAL.CURIE.field_id: "_field/Test_sub_field",
                 ANNAL.CURIE.field_placement: "small:0,12"
             }],
             ANNAL.CURIE.repeat_label_add:
             "Add sub entity",
             ANNAL.CURIE.repeat_label_delete:
             "Remove sub entity"
         })
     self.assertTrue(self.test_sub_list is not None)
     # Create test view using superproperty
     self.test_view = RecordView.create(
         self.testcoll, "testlistview", {
             ANNAL.CURIE.type:
             "annal:View",
             ANNAL.CURIE.uri:
             "test:listview",
             RDFS.CURIE.label:
             "Test listview label",
             RDFS.CURIE.comment:
             "Test listview comment",
             ANNAL.CURIE.view_entity_type:
             "test:testtype",
             ANNAL.CURIE.view_fields:
             [{
                 ANNAL.CURIE.field_id: layout.FIELD_TYPEID + "/Entity_id",
                 ANNAL.CURIE.field_placement: "small:0,12;medium:0,6"
             }, {
                 ANNAL.CURIE.field_id:
                 layout.FIELD_TYPEID + "/Test_sup_list",
                 ANNAL.CURIE.field_placement: "small:0,12;medium:0,6"
             }]
         })
     self.assertTrue(self.test_view is not None)
     # Create test entity using list and item subproperty URIs
     self.testlistentity_data = EntityData.create(
         self.testdata, "testlistentity",
         entitydata_create_values("testlistentity",
                                  type_id="testtype",
                                  type_uri="test:testtype",
                                  extra_fields={
                                      "test:subprop_list_uri": [{
                                          "test:subprop_uri":
                                          "Test field 1 value"
                                      }, {
                                          "test:subprop_uri":
                                          "Test field 2 value"
                                      }]
                                  }))
     self.assertTrue(self.testlistentity_data is not None)
     return