Ejemplo n.º 1
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
Ejemplo n.º 2
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
Ejemplo n.º 3
0
 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
Ejemplo n.º 4
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
Ejemplo n.º 5
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
Ejemplo n.º 6
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
Ejemplo n.º 7
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
Ejemplo n.º 8
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
Ejemplo n.º 9
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
Ejemplo n.º 10
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
Ejemplo n.º 11
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
Ejemplo n.º 12
0
 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
Ejemplo n.º 13
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
Ejemplo n.º 14
0
 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_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
Ejemplo n.º 16
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
 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
Ejemplo n.º 18
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
Ejemplo n.º 19
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
Ejemplo n.º 20
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
Ejemplo n.º 21
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
Ejemplo n.º 22
0
 def create_field_record(self, coll, field_entity):
     return RecordField.create(coll, field_entity.get_id(), field_entity.get_values())
Ejemplo n.º 23
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
Ejemplo n.º 24
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
Ejemplo n.º 25
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
Ejemplo n.º 26
0
 def create_field_record(self, coll, field_entity):
     return RecordField.create(coll, field_entity.get_id(),
                               field_entity.get_values())