コード例 #1
0
def init_annalist_named_test_coll(base_coll_id=None,
                                  coll_id="testcoll",
                                  type_id="testtype"):
    """
    Similar to init_annalist_test_coll, but collection also installs and 
    inherits from named collection definitions.

    """
    # @@TODO: DRY: use create_test_coll_inheriting
    # @@TODO: rename: install_create_test_coll_inheriting
    log.debug("init_annalist_named_test_coll")
    testsite = Site(TestBaseUri, TestBaseDir)
    namedcoll = install_annalist_named_coll(base_coll_id)
    testcoll = Collection.create(testsite, coll_id,
                                 collection_create_values(coll_id))
    testcoll.set_alt_entities(namedcoll)
    testcoll._save()
    testtype = RecordType.create(testcoll, type_id,
                                 recordtype_create_values(coll_id, type_id))
    testdata = RecordTypeData.create(testcoll, type_id, {})
    teste = EntityData.create(
        testdata, "entity1",
        entitydata_create_values(testcoll, testtype, "entity1"))
    testcoll.generate_coll_jsonld_context()
    return testcoll
コード例 #2
0
def coll123_create_data(site):
    coll1 = Collection.create(site, "coll1", collection_create_values("coll1"))
    coll2 = Collection.create(site, "coll2", collection_create_values("coll2"))
    coll3 = Collection.create(site, "coll3", collection_create_values("coll3"))
    #
    for coll in [coll1, coll2, coll3]:
        type1 = RecordType.create(
            coll, "type1", recordtype_create_values(coll._entityid, "type1"))
        view1 = RecordView.create(
            coll, "view1", recordview_create_values(coll._entityid, "view1"))
        list1 = RecordList.create(
            coll, "list1", recordlist_create_values(coll._entityid, "list1"))
        data1 = RecordTypeData.create(coll, "type1", {})
        type2 = RecordType.create(
            coll, "type2", recordtype_create_values(coll._entityid, "type2"))
        view2 = RecordView.create(
            coll, "view2", recordview_create_values(coll._entityid, "view2"))
        list2 = RecordList.create(
            coll, "list2", recordlist_create_values(coll._entityid, "list2"))
        data2 = RecordTypeData.create(coll, "type2", {})
        #
        for t, d in [(type1, data1), (type2, data2)]:
            for eid in ["entity1", "entity2", "entity3"]:
                e = EntityData.create(d, eid,
                                      entitydata_create_values(coll, t, eid))
    return
コード例 #3
0
 def _create_testentity(self):
     testentity = EntityData.create(self.testdata, "testentity", {
         "annal:type": "test:testtype",
         "test:repeat_fields": []
     })
     self.assertTrue(testentity is not None)
     return testentity
コード例 #4
0
def create_test_coll_inheriting(base_coll_id=None,
                                coll_id="testcoll",
                                type_id="testtype"):
    """
    Similar to init_annalist_test_coll, but collection also
    inherits from named collection.
    """
    testsite = Site(TestBaseUri, TestBaseDir)
    basecoll = Collection.load(testsite, base_coll_id)
    if not basecoll:
        msg = "Base collection %s not found" % base_coll_id
        log.warning(msg)
        assert False, msg
    testcoll = Collection.create(testsite, coll_id,
                                 collection_create_values(coll_id))
    testcoll.set_alt_entities(basecoll)
    testcoll._save()
    testtype = RecordType.create(testcoll, type_id,
                                 recordtype_create_values(coll_id, type_id))
    testdata = RecordTypeData.create(testcoll, type_id, {})
    teste = EntityData.create(
        testdata, "entity1",
        entitydata_create_values(testcoll, testtype, "entity1"))
    testcoll.generate_coll_jsonld_context()
    return testcoll
コード例 #5
0
 def _create_record_type(self, type_id, entity_id="testentity"):
     "Helper function creates record type entry with supplied type_id"
     t = RecordType.create(self.testcoll, type_id,
                           recordtype_create_values(type_id=type_id))
     d = RecordTypeData.create(self.testcoll, type_id, {})
     e = EntityData.create(d, entity_id, {})
     return (t, d, e)
コード例 #6
0
 def _create_testentity(self):
     testentity = EntityData.create(self.testdata, "testentity",
         { "annal:type":         "test:testtype"
         , "test:repeat_fields": []
         })
     self.assertTrue(testentity is not None)
     return testentity
コード例 #7
0
 def setUp(self):
     init_annalist_test_site()
     self.testsite  = Site(TestBaseUri, TestBaseDir)
     self.testcoll  = Collection.create(self.testsite, "testcoll", collection_create_values("testcoll"))
     self.testtype  = RecordType.create(self.testcoll, "testtype", recordtype_create_values("testcoll", "testtype"))
     self.testtype2 = RecordType.create(self.testcoll, "testtype2", recordtype_create_values("testcoll", "testtype2"))
     self.testdata  = RecordTypeData.create(self.testcoll, "testtype", {})
     self.testdata2 = RecordTypeData.create(self.testcoll, "testtype2", {})
     e1 = self._create_entity_data("entity1")
     e2 = self._create_entity_data("entity2")
     e3 = self._create_entity_data("entity3")
     e4 = EntityData.create(self.testdata2, "entity4", 
         entitydata_create_values("entity4", type_id="testtype2")
         )
     self.type_ids = get_site_types_linked("testcoll")
     self.type_ids.append(FieldChoice("_type/testtype", 
             label="RecordType testcoll/_type/testtype",
             link=recordtype_url("testcoll", "testtype")
         ))
     self.type_ids.append(FieldChoice("_type/testtype2", 
             label="RecordType testcoll/_type/testtype2",
             link=recordtype_url("testcoll", "testtype2")
         ))
     self.list_ids = get_site_lists_linked("testcoll")
     # 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
コード例 #8
0
 def setUp(self):
     init_annalist_test_site()
     self.testsite = Site(TestBaseUri, TestBaseDir)
     self.testcoll = Collection.create(self.testsite, "testcoll",
                                       collection_create_values("testcoll"))
     self.testtype = RecordType.create(
         self.testcoll, "testtype",
         recordtype_create_values("testcoll", "testtype"))
     self.testtype2 = RecordType.create(
         self.testcoll, "testtype2",
         recordtype_create_values("testcoll", "testtype2"))
     self.testdata = RecordTypeData.create(self.testcoll, "testtype", {})
     self.testdata2 = RecordTypeData.create(self.testcoll, "testtype2", {})
     e1 = self._create_entity_data("entity1")
     e2 = self._create_entity_data("entity2")
     e3 = self._create_entity_data("entity3")
     e4 = EntityData.create(
         self.testdata2, "entity4",
         entitydata_create_values("entity4", type_id="testtype2"))
     self.type_ids = get_site_types_linked("testcoll")
     self.type_ids.append(
         FieldChoice("testtype",
                     label="RecordType testcoll/testtype",
                     link=recordtype_url("testcoll", "testtype")))
     self.list_ids = get_site_lists_linked("testcoll")
     # 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
コード例 #9
0
 def test_entitydata_create_load(self):
     e  = EntityData.create(self.testdata, "entitydata1", entitydata_create_values("entitydata1"))
     self.assertEqual(e._entitydir, entitydata_dir(entity_id="entitydata1"))
     self.assertTrue(os.path.exists(e._entitydir))
     ed = EntityData.load(self.testdata, "entitydata1").get_values()
     v  = entitydata_values("entitydata1")
     self.assertKeysMatch(ed, v)
     self.assertDictionaryMatch(ed, v)
     return
コード例 #10
0
 def _create_ref_entity(self):
     ref_entity = EntityData.create(self.ref_data, "Test_ref_entity",
         { "annal:type":         "test:ref_type"
         , "rdfs:label":         "Label Test_ref_entity"
         , "rdfs:comment":       "Description of reference image record"
         , "test:ref_image":     "Test_img_entity"
         })
     self.assertTrue(ref_entity is not None)
     return ref_entity
コード例 #11
0
 def create_data(self, entity_id):
     # Create placeholder for testing
     typedata = RecordTypeData.create(self.testcoll, "Default_type", {})
     assert typedata is not None
     e = EntityData.create(
         typedata, entity_id,
         entitydata_create_values(entity_id,
                                  coll_id="testcoll",
                                  type_id="Default_type"))
     return e
コード例 #12
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
コード例 #13
0
 def _create_entity_data(self, 
     entity_id, type_id="testtype", update="Entity", 
     comment2="Comment field 2",
     comment3="Comment field 3"
     ):
     "Helper function creates entity data with supplied entity_id"
     v = entitydata_create_values(entity_id, type_id=type_id, update=update)
     v = entitydata_values_add_field(v, "rdfs:comment", 2, comment2)
     v = entitydata_values_add_field(v, "rdfs:comment_alt", 3, comment3)
     e = EntityData.create(self.testdata, entity_id, v)
     return e    
コード例 #14
0
 def _create_entity_data(self, 
     entity_id, type_id="testtype", update="Entity", 
     comment2="Comment field 2",
     comment3="Comment field 3"
     ):
     "Helper function creates entity data with supplied entity_id"
     v = entitydata_create_values(entity_id, type_id=type_id, update=update)
     v = entitydata_values_add_field(v, "rdfs:comment", 2, comment2)
     v = entitydata_values_add_field(v, "rdfs:comment_alt", 3, comment3)
     e = EntityData.create(self.testdata, entity_id, v)
     return e    
コード例 #15
0
 def setUp(self):
     self.testsite = init_annalist_test_site()
     self.testcoll = init_annalist_named_test_coll(layout.BIBDATA_ID)
     # Create BibEntry record (BibEntry_type defines field alias)
     self.testdata = RecordTypeData.create(self.testcoll, "BibEntry_type",
                                           {})
     self.bibentity1_data = ({
         "@type": ["bib:BibEntry", ANNAL.CURIE.EntityData],
         ANNAL.CURIE.type:
         "bib:BibEntry",
         ANNAL.CURIE.type_id:
         "BibEntry_type",
         "bib:type":
         "article",
         "bib:title":
         "bib:title for bibentity1",
         "bib:note":
         "Sample bibliographic entry with field aliasing",
         "bib:month":
         "09",
         "bib:year":
         "2014",
         "bib:author": [{
             "bib:id": "author_id",
             "bib:name": "Author, J. H.",
             "bib:alternate": "Joe H. Author",
             "bib:firstname": "Joe",
             "bib:lastname": "Author"
         }],
         "bib:identifier": [],
         "bib:journal": [],
         "bib:editor": [],
         "bib:publication_details": [],
         "bib:license": [],
         "bib:bookentry": []
     })
     self.testbib1 = EntityData.create(self.testdata, "bibentity1",
                                       self.bibentity1_data)
     # 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
コード例 #16
0
ファイル: test_entitydelete.py プロジェクト: gklyne/annalist
 def test_post_confirmed_remove_entity(self):
     t = EntityData.create(self.testdata, "deleteentity", entitydata_create_values("deleteentity"))
     self.assertTrue(EntityData.exists(self.testdata, "deleteentity"))
     # Submit positive confirmation
     u = entitydata_delete_confirm_url("testcoll", "testtype")
     f = entitydata_delete_confirm_form_data("deleteentity")
     r = self.client.post(u, f)
     self.assertEqual(r.status_code,    302)
     self.assertEqual(r.reason_phrase,  "Found")
     self.assertEqual(r.content,        b"")
     v  = entitydata_list_all_url("testcoll")
     self.assertIn(v, r['location'])
     self.assertIn("info_head=",         r['location'])
     self.assertIn("info_message=",      r['location'])
     self.assertNotIn("search=testcoll", r['location'])
     # Confirm deletion
     self.assertFalse(EntityData.exists(self.testcoll, "deleteentity"))
     return
コード例 #17
0
def coll123_create_data(site):
    coll1 = Collection.create(site, "coll1", collection_create_values("coll1"))
    coll2 = Collection.create(site, "coll2", collection_create_values("coll2"))
    coll3 = Collection.create(site, "coll3", collection_create_values("coll3"))
    #
    for coll in [coll1, coll2, coll3]:
        type1 = RecordType.create(coll, "type1", recordtype_create_values(coll._entityid, "type1"))
        view1 = RecordView.create(coll, "view1", recordview_create_values(coll._entityid, "view1"))
        list1 = RecordList.create(coll, "list1", recordlist_create_values(coll._entityid, "list1"))
        data1 = RecordTypeData.create(coll, "type1", {})
        type2 = RecordType.create(coll, "type2", recordtype_create_values(coll._entityid, "type2"))
        view2 = RecordView.create(coll, "view2", recordview_create_values(coll._entityid, "view2"))
        list2 = RecordList.create(coll, "list2", recordlist_create_values(coll._entityid, "list2"))
        data2 = RecordTypeData.create(coll, "type2", {})
        #
        for t,d in [(type1,data1),(type2,data2)]:
            for eid in ["entity1", "entity2", "entity3"]:
                e = EntityData.create(d, eid, entitydata_create_values(coll,t,eid))
    return
コード例 #18
0
 def test_CreateTestSiteData(self):
     copySitedata(
         settings.SITE_SRC_ROOT + "/sampledata/init/" +
         test_layout.SITE_DIR,
         settings.SITE_SRC_ROOT + "/annalist/sitedata", TestBaseDir)
     testsite = Site(TestBaseUri, TestBaseDir)
     coll123_create_data(testsite)
     #
     testcoll = Collection.create(testsite, "testcoll",
                                  collection_create_values("testcoll"))
     testtype = RecordType.create(testcoll, "testtype",
                                  recordtype_create_values("testtype"))
     # testview = RecordView.create(testcoll, "testview", recordview_create_values("testview"))
     # testlist = RecordList.create(testcoll, "testlist", recordlist_create_values("testlist"))
     testdata = RecordTypeData.create(testcoll, "testtype", {})
     teste = EntityData.create(
         testdata, "entity1",
         entitydata_create_values(testcoll, testtype, "entity1"))
     return
コード例 #19
0
ファイル: init_tests.py プロジェクト: juandesant/annalist
def init_annalist_test_coll(coll_id="testcoll", type_id="testtype"):
    log.debug("init_annalist_test_coll")
    testsite = Site(TestBaseUri, TestBaseDir)
    testcoll = Collection.create(testsite, coll_id, collection_create_values(coll_id))
    testtype = RecordType.create(testcoll, type_id, recordtype_create_values(coll_id, type_id))
    testdata = RecordTypeData.create(testcoll, type_id, {})
    teste    = EntityData.create(
        testdata, "entity1", 
        entitydata_create_values(testcoll,testtype,"entity1")
        )
    testcoll.generate_coll_jsonld_context()
    # Reset id generator counters
    EntityData._last_id   = 0
    RecordType._last_id   = 0
    RecordView._last_id   = 0
    RecordList._last_id   = 0
    RecordField._last_id  = 0
    AnnalistUser._last_id = 0
    return testcoll
コード例 #20
0
 def setUp(self):
     self.testsite  = init_annalist_test_site()
     self.testcoll  = init_annalist_named_test_coll(layout.BIBDATA_ID)
     self.testdata  = RecordTypeData.load(self.testcoll, "testtype")
     self.testtype2 = RecordType.create(
         self.testcoll, "testtype2", recordtype_create_values("testcoll", "testtype2")
         )
     self.testdata2 = RecordTypeData.create(self.testcoll, "testtype2", {})
     create_test_user(self.testcoll, "testuser", "testpassword")
     self.client = Client(HTTP_HOST=TestHost)
     loggedin = self.client.login(username="******", password="******")
     self.assertTrue(loggedin)
     e1 = self._create_entity_data("entity1")
     e2 = self._create_entity_data("entity2")
     e3 = self._create_entity_data("entity3")
     e4 = EntityData.create(self.testdata2, "entity4", 
         entitydata_create_values("entity4", type_id="testtype2")
         )
     self.list_ids = get_site_bib_lists_linked("testcoll")
     return
コード例 #21
0
 def setUp(self):
     self.testsite  = init_annalist_test_site()
     self.testcoll  = init_annalist_named_test_coll(layout.BIBDATA_ID)
     self.testdata  = RecordTypeData.load(self.testcoll, "testtype")
     self.testtype2 = RecordType.create(
         self.testcoll, "testtype2", recordtype_create_values("testcoll", "testtype2")
         )
     self.testdata2 = RecordTypeData.create(self.testcoll, "testtype2", {})
     create_test_user(self.testcoll, "testuser", "testpassword")
     self.client = Client(HTTP_HOST=TestHost)
     loggedin = self.client.login(username="******", password="******")
     self.assertTrue(loggedin)
     e1 = self._create_entity_data("entity1")
     e2 = self._create_entity_data("entity2")
     e3 = self._create_entity_data("entity3")
     e4 = EntityData.create(self.testdata2, "entity4", 
         entitydata_create_values("entity4", type_id="testtype2")
         )
     self.list_ids = get_site_bib_lists_linked("testcoll")
     return
コード例 #22
0
def init_annalist_test_coll(coll_id="testcoll", type_id="testtype"):
    log.debug("init_annalist_test_coll")
    testsite = Site(TestBaseUri, TestBaseDir)
    testcoll = Collection.create(testsite, coll_id,
                                 collection_create_values(coll_id))
    testtype = RecordType.create(testcoll, type_id,
                                 recordtype_create_values(coll_id, type_id))
    testdata = RecordTypeData.create(testcoll, type_id, {})
    teste = EntityData.create(
        testdata, "entity1",
        entitydata_create_values(testcoll, testtype, "entity1"))
    testcoll.generate_coll_jsonld_context()
    # Reset id generator counters
    EntityData._last_id = 0
    RecordType._last_id = 0
    RecordView._last_id = 0
    RecordList._last_id = 0
    RecordField._last_id = 0
    AnnalistUser._last_id = 0
    return testcoll
コード例 #23
0
 def test_post_confirmed_remove_entity_from_search(self):
     t = EntityData.create(self.testdata, "deleteentity", entitydata_create_values("deleteentity"))
     self.assertTrue(EntityData.exists(self.testdata, "deleteentity"))
     # Submit positive confirmation
     u = entitydata_delete_confirm_url("testcoll", "testtype")
     f = entitydata_delete_confirm_form_data("deleteentity", search="testcoll")
     r = self.client.post(u, f)
     self.assertEqual(r.status_code,     302)
     self.assertEqual(r.reason_phrase,   "FOUND")
     self.assertEqual(r.content,         "")
     self.assertMatch(r['location'],    
         "^"+TestHostUri+
         entitydata_list_all_url("testcoll")
         )
     self.assertMatch(r['location'],    
         r"info_head=.*&info_message=.*deleteentity.*testcoll.*$"
         )
     self.assertIn("search=testcoll", r['location'])
     # Confirm deletion
     self.assertFalse(EntityData.exists(self.testcoll, "deleteentity"))
     return
コード例 #24
0
 def setUp(self):
     init_annalist_test_site()
     self.testsite  = Site(TestBaseUri, TestBaseDir)
     self.testcoll  = Collection.create(self.testsite, "testcoll", collection_create_values("testcoll"))
     self.testtype  = RecordType.create(self.testcoll, "testtype", recordtype_create_values("testcoll", "testtype"))
     self.testtype2 = RecordType.create(self.testcoll, "testtype2", recordtype_create_values("testcoll", "testtype2"))
     self.testdata  = RecordTypeData.create(self.testcoll, "testtype", {})
     self.testdata2 = RecordTypeData.create(self.testcoll, "testtype2", {})
     # self.user = User.objects.create_user('testuser', '*****@*****.**', 'testpassword')
     # self.user.save()
     create_test_user(self.testcoll, "testuser", "testpassword")
     self.client = Client(HTTP_HOST=TestHost)
     loggedin = self.client.login(username="******", password="******")
     self.assertTrue(loggedin)
     e1 = self._create_entity_data("entity1")
     e2 = self._create_entity_data("entity2")
     e3 = self._create_entity_data("entity3")
     e4 = EntityData.create(self.testdata2, "entity4", 
         entitydata_create_values("entity4", type_id="testtype2")
         )
     self.list_ids = get_site_lists_linked("testcoll")
     return
コード例 #25
0
ファイル: test_field_alias.py プロジェクト: gklyne/annalist
 def setUp(self):
     self.testsite  = init_annalist_test_site()
     self.testcoll  = init_annalist_named_test_coll(layout.BIBDATA_ID)
     # Create BibEntry record (BibEntry_type defines field alias)
     self.testdata   = RecordTypeData.create(self.testcoll, "BibEntry_type", {})
     self.bibentity1_data = (
         { "@type": 
             [ "bib:BibEntry"
             , ANNAL.CURIE.EntityData
             ]
         , ANNAL.CURIE.type:    "bib:BibEntry"
         , ANNAL.CURIE.type_id: "BibEntry_type"
         , "bib:type": "article"
         , "bib:title": "bib:title for bibentity1"
         , "bib:note": "Sample bibliographic entry with field aliasing"
         , "bib:month": "09"
         , "bib:year": "2014"
         , "bib:author": [
             { "bib:id": "author_id"
             , "bib:name": "Author, J. H."
             , "bib:alternate": "Joe H. Author"
             , "bib:firstname": "Joe"
             , "bib:lastname": "Author"
             }]
         , "bib:identifier": []
         , "bib:journal": []
         , "bib:editor": []
         , "bib:publication_details": []
         , "bib:license": []
         , "bib:bookentry": []
         })
     self.testbib1   = EntityData.create(self.testdata, "bibentity1", self.bibentity1_data)
     # 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
コード例 #26
0
ファイル: init_tests.py プロジェクト: juandesant/annalist
def init_annalist_named_test_coll(
        base_coll_id=None, coll_id="testcoll", type_id="testtype"):
    """
    Similar to init_annalist_test_coll, but collection also installs and 
    inherits from named collection definitions.

    """
    # @@TODO: DRY: use create_test_coll_inheriting
    # @@TODO: rename: install_create_test_coll_inheriting
    log.debug("init_annalist_named_test_coll")
    testsite  = Site(TestBaseUri, TestBaseDir)
    namedcoll = install_annalist_named_coll(base_coll_id)
    testcoll  = Collection.create(testsite, coll_id, collection_create_values(coll_id))
    testcoll.set_alt_entities(namedcoll)
    testcoll._save()
    testtype  = RecordType.create(testcoll, type_id, recordtype_create_values(coll_id, type_id))
    testdata  = RecordTypeData.create(testcoll, type_id, {})
    teste     = EntityData.create(
        testdata, "entity1", 
        entitydata_create_values(testcoll, testtype, "entity1")
        )
    testcoll.generate_coll_jsonld_context()
    return testcoll
コード例 #27
0
ファイル: init_tests.py プロジェクト: juandesant/annalist
def create_test_coll_inheriting(
        base_coll_id=None, coll_id="testcoll", type_id="testtype"):
    """
    Similar to init_annalist_test_coll, but collection also
    inherits from named collection.
    """
    testsite  = Site(TestBaseUri, TestBaseDir)
    basecoll  = Collection.load(testsite, base_coll_id)
    if not basecoll:
        msg = "Base collection %s not found"%base_coll_id
        log.warning(msg)
        assert False, msg
    testcoll  = Collection.create(testsite, coll_id, collection_create_values(coll_id))
    testcoll.set_alt_entities(basecoll)
    testcoll._save()
    testtype  = RecordType.create(testcoll, type_id, recordtype_create_values(coll_id, type_id))
    testdata  = RecordTypeData.create(testcoll, type_id, {})
    teste     = EntityData.create(
        testdata, "entity1", 
        entitydata_create_values(testcoll, testtype, "entity1")
        )
    testcoll.generate_coll_jsonld_context()
    return testcoll
コード例 #28
0
 def _create_img_entity(self):
     # Create entity associated with uploaded image
     self.img_entity = EntityData.create(
         self.img_data, "Test_img_entity", {
             "annal:type": "test:img_type",
             "rdfs:label": "Label Test_img_entity",
             "rdfs:comment": "Description of image",
             "test:image": {
                 'upload_name': "image_field",
                 'resource_name': "image_field.jpeg",
                 'resource_type': "image/jpeg",
                 'uploaded_file': self.imagename,
                 'uploaded_size': 1547926
             }
         })
     self.assertTrue(self.img_entity is not None)
     # Store image in entity directory
     img_fileobj = self.img_entity._fileobj("image_field", "annal:Image",
                                            "image/jpeg", "wb")
     with open(self.imagepath, "rb") as siteobj:
         img_fileobj.write(siteobj.read())
     img_fileobj.close()
     return self.img_entity
コード例 #29
0
 def test_post_confirmed_remove_entity_from_search(self):
     t = EntityData.create(self.testdata, "deleteentity", entitydata_create_values("deleteentity"))
     self.assertTrue(EntityData.exists(self.testdata, "deleteentity"))
     # Submit positive confirmation
     u = entitydata_delete_confirm_url("testcoll", "testtype")
     f = entitydata_delete_confirm_form_data("deleteentity", search="testcoll")
     r = self.client.post(u, f)
     self.assertEqual(r.status_code,     302)
     self.assertEqual(r.reason_phrase,   "FOUND")
     self.assertEqual(r.content,         "")
     self.assertMatch(r['location'],    
         "^"+TestHostUri+
         entitydata_list_all_url("testcoll")
         )
     self.assertMatch(r['location'],    
         r"info_head=.*$"
         )
     self.assertMatch(r['location'],    
         r"info_message=.*deleteentity.*testcoll.*$"
         )
     self.assertIn("search=testcoll", r['location'])
     # Confirm deletion
     self.assertFalse(EntityData.exists(self.testcoll, "deleteentity"))
     return
コード例 #30
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
コード例 #31
0
 def setUp(self):
     init_annalist_test_site()
     self.testsite  = Site(TestBaseUri, TestBaseDir)
     self.testcoll  = Collection.create(
         self.testsite, "testcoll", collection_create_values("testcoll")
         )
     # Create test types
     self.testtypes = RecordType.create(
         self.testcoll, "testtypes", 
         recordtype_create_values(
             coll_id="testcoll", type_id="testtypes", type_uri="test:testtypes",
             supertype_uris=[]
             )
         )
     self.testtype1 = RecordType.create(
         self.testcoll, "testtype1",
         recordtype_create_values(
             coll_id="testcoll", type_id="testtype1", type_uri="test:testtype1", 
             supertype_uris=["test:testtypes"]
             )
         )
     self.testtype2 = RecordType.create(
         self.testcoll, "testtype2",
         recordtype_create_values(
             coll_id="testcoll", type_id="testtype2", type_uri="test:testtype2", 
             supertype_uris=["test:testtypes"]
             )
         )
     self.ref_type  = RecordType.create(
         self.testcoll, "ref_type", 
         recordtype_create_values(
             coll_id="testcoll", type_id="ref_type", type_uri="test:ref_type",
             supertype_uris=[]
             )
         )
     # Create test type data parents
     self.testdatas = RecordTypeData.create(self.testcoll, "testtypes", {})
     self.testdata1 = RecordTypeData.create(self.testcoll, "testtype1", {})
     self.testdata2 = RecordTypeData.create(self.testcoll, "testtype2", {})
     self.ref_data  = RecordTypeData.create(self.testcoll, "ref_type",  {})
     # Create test type data
     es = EntityData.create(self.testdatas, "entitys", 
         entitydata_create_values(
             "entitys", type_id="testtypes", extra_fields={"test:turi": "test:testtypes"} 
             )
         )
     e1 = EntityData.create(self.testdata1, "entity1", 
         entitydata_create_values(
             "entity1", type_id="testtype1", extra_fields={"test:turi": "test:testtype1"} 
             )
         )
     e2 = EntityData.create(self.testdata2, "entity2", 
         entitydata_create_values(
             "entity2", type_id="testtype2", extra_fields={"test:turi": "test:testtype2"} 
             )
         )
     # 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
コード例 #32
0
 def _create_record_type(self, type_id, entity_id="testentity"):
     "Helper function creates record type entry with supplied type_id"
     t = RecordType.create(self.testcoll, type_id, recordtype_create_values(type_id=type_id))
     d = RecordTypeData.create(self.testcoll, type_id, {})
     e = EntityData.create(d, entity_id, {})
     return (t, d, e)
コード例 #33
0
 def setUp(self):
     init_annalist_test_site()
     self.testsite = Site(TestBaseUri, TestBaseDir)
     self.testcoll = Collection.create(self.testsite, "testcoll",
                                       collection_create_values("testcoll"))
     # Create test types
     self.testtypes = RecordType.create(
         self.testcoll, "testtypes",
         recordtype_create_values(coll_id="testcoll",
                                  type_id="testtypes",
                                  type_uri="test:testtypes",
                                  supertype_uris=[]))
     self.testtype1 = RecordType.create(
         self.testcoll, "testtype1",
         recordtype_create_values(coll_id="testcoll",
                                  type_id="testtype1",
                                  type_uri="test:testtype1",
                                  supertype_uris=["test:testtypes"]))
     self.testtype2 = RecordType.create(
         self.testcoll, "testtype2",
         recordtype_create_values(coll_id="testcoll",
                                  type_id="testtype2",
                                  type_uri="test:testtype2",
                                  supertype_uris=["test:testtypes"]))
     self.ref_type = RecordType.create(
         self.testcoll, "ref_type",
         recordtype_create_values(coll_id="testcoll",
                                  type_id="ref_type",
                                  type_uri="test:ref_type",
                                  supertype_uris=[]))
     # Create test type data parents
     self.testdatas = RecordTypeData.create(self.testcoll, "testtypes", {})
     self.testdata1 = RecordTypeData.create(self.testcoll, "testtype1", {})
     self.testdata2 = RecordTypeData.create(self.testcoll, "testtype2", {})
     self.ref_data = RecordTypeData.create(self.testcoll, "ref_type", {})
     # Create test type data
     es = EntityData.create(
         self.testdatas, "entitys",
         entitydata_create_values(
             "entitys",
             type_id="testtypes",
             extra_fields={"test:turi": "test:testtypes"}))
     e1 = EntityData.create(
         self.testdata1, "entity1",
         entitydata_create_values(
             "entity1",
             type_id="testtype1",
             extra_fields={"test:turi": "test:testtype1"}))
     e2 = EntityData.create(
         self.testdata2, "entity2",
         entitydata_create_values(
             "entity2",
             type_id="testtype2",
             extra_fields={"test:turi": "test:testtype2"}))
     # 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
コード例 #34
0
 def _create_entity_data(self, entity_id, update="Entity"):
     "Helper function creates entity data with supplied entity_id"
     e = EntityData.create(self.testdata, entity_id, 
         entitydata_create_values(entity_id, update=update)
         )
     return e    
コード例 #35
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
コード例 #36
0
 def _create_entity_data(self, entity_id, update="Entity"):
     "Helper function creates entity data in 'testcoll/testtype' with supplied id"
     e = EntityData.create(self.testdata, entity_id, 
         entitydata_create_values(entity_id, update=update)
         )
     return e    
コード例 #37
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