コード例 #1
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
コード例 #2
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
コード例 #3
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
コード例 #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 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
コード例 #6
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("testtype"))
        self.testdata = RecordTypeData.create(self.testcoll, "testtype", {})

        # Create view with duplicate field id
        self.viewdata = recordview_create_values(view_id="DupField_view")
        recordview_values_add_field(
            self.viewdata, 
            field_id="Entity_comment", 
            field_placement="small:0,12"
            )
        recordview_values_add_field(
            self.viewdata, 
            field_id="Entity_comment",
            field_property_uri="rdfs:comment_alt",
            field_placement="small:0,12"
            )
        self.testview = RecordView.create(self.testcoll, "DupField_view", self.viewdata)

        # 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
コード例 #7
0
 def test_set_alt_entities_2(self):
     coll_id   = "altcoll1"
     altcoll1  = Collection.create(self.testsite, coll_id, collection_create_values(coll_id))
     parents   = altcoll1.set_alt_entities(self.testcoll)
     parentids = [ p.get_id() for p in parents ]
     self.assertEqual( parentids, ["altcoll1", "testcoll", layout.SITEDATA_ID])
     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("testtype"))
        self.testdata = RecordTypeData.create(self.testcoll, "testtype", {})

        # Create view with duplicate field id
        self.viewdata = recordview_create_values(view_id="DupField_view")
        recordview_values_add_field(self.viewdata,
                                    field_id="Entity_comment",
                                    field_placement="small:0,12")
        recordview_values_add_field(self.viewdata,
                                    field_id="Entity_comment",
                                    field_property_uri="rdfs:comment_alt",
                                    field_placement="small:0,12")
        self.testview = RecordView.create(self.testcoll, "DupField_view",
                                          self.viewdata)

        # 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 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
コード例 #10
0
 def setUp(self):
     init_annalist_test_site()
     self.testsite = Site(TestBaseUri, TestBaseDir)
     self.testcoll = Collection.create(self.testsite, "testcoll", collection_create_values("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
コード例 #11
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.user = User.objects.create_user('testuser', '*****@*****.**', 'testpassword')
     self.user.save()
     self.client = Client(HTTP_HOST=TestHost)
     loggedin = self.client.login(username="******", password="******")
     self.assertTrue(loggedin)
     return
コード例 #12
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.sitecoll = Collection.load(self.testsite, layout.SITEDATA_ID)
     self.client   = Client(HTTP_HOST=TestHost)
     self.uri      = reverse("AnnalistServerLogView")
     self.homeuri  = reverse("AnnalistHomeView")
     return
コード例 #13
0
 def test_alt_parent_inherit_site(self):
     # Test inheritance of definitions from site with an alternative collection set
     coll_id = "newcoll"
     newcoll = Collection.create(self.testsite, coll_id, collection_create_values(coll_id))
     altparents = newcoll.set_alt_entities(self.testcoll)
     parentids  = [ p.get_id() for p in altparents ]
     self.assertEqual(parentids, ["newcoll", "testcoll", layout.SITEDATA_ID])
     self.assertTrue(RecordType.exists(newcoll, "Default_type", altscope="all"))
     def_type = RecordType.load(newcoll, "Default_type", altscope="all")
     self.assertEquals(def_type["rdfs:label"], "Default record")
     return
コード例 #14
0
 def setUp(self):
     init_annalist_test_site()
     self.testsite = Site(TestBaseUri, TestBaseDir)
     self.testcoll = Collection.create(self.testsite, "testcoll",
                                       collection_create_values("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
コード例 #15
0
ファイル: site.py プロジェクト: josemanuelgp/annalist
    def add_collection(self, coll_id, coll_meta):
        """
        Add a new collection to the current site

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

        returns a Collection object for the newly created collection.
        """
        c = Collection.create(self, coll_id, coll_meta)
        return c
コード例 #16
0
 def setUp(self):
     # Set up basic site data
     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("testtype"))
     self.testdata = RecordTypeData.create(self.testcoll, "testtype", {})
     # 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
コード例 #17
0
 def setUp(self):
     # Set up basic site data
     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("testtype"))
     self.testdata = RecordTypeData.create(self.testcoll, "testtype", {})
     # 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
コード例 #18
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.user = User.objects.create_user('testuser',
                                          '*****@*****.**',
                                          'testpassword')
     self.user.save()
     self.client = Client(HTTP_HOST=TestHost)
     loggedin = self.client.login(username="******",
                                  password="******")
     self.assertTrue(loggedin)
     return
コード例 #19
0
 def setUp(self):
     init_annalist_test_site()
     self.testsite = Site(TestBaseUri, TestBaseDir)
     self.testcoll = Collection.create(self.testsite, "testcoll", collection_create_values("testcoll"))
     # Login and permissions
     create_test_user(
         self.testsite.site_data_collection(),
         # self.testcoll, 
         "testuser", "testpassword",
         user_permissions=["VIEW", "CREATE", "UPDATE", "DELETE", "CONFIG", "ADMIN"]
         )
     self.client = Client(HTTP_HOST=TestHost)
     loggedin = self.client.login(username="******", password="******")
     self.assertTrue(loggedin)
     return
コード例 #20
0
 def test_alt_parent_inherit_user(self):
     # Test inheritance of "user" scope definitions
     coll_id = "newcoll"
     newcoll = Collection.create(self.testsite, coll_id, collection_create_values(coll_id))
     user1   = AnnalistUser.create(self.testcoll, "user1", annalistuser_create_values(user_id="user1"))
     user2   = AnnalistUser.create(newcoll,       "user2", annalistuser_create_values(user_id="user2"))
     altparents = newcoll.set_alt_entities(self.testcoll)
     parentids  = [ p.get_id() for p in altparents ]
     self.assertEqual(parentids, ["newcoll", "testcoll", layout.SITEDATA_ID])
     self.assertFalse(AnnalistUser.exists(newcoll, "user1", altscope="user"))
     self.assertTrue(AnnalistUser.exists(newcoll, "_default_user_perms", altscope="user"))   # Access site data
     self.assertTrue(AnnalistUser.exists(newcoll, "user2", altscope="user"))
     testuser = AnnalistUser.load(newcoll, "user2", altscope="user")
     self.assertEquals(testuser["rdfs:label"], "Test User")
     return
コード例 #21
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.no_options = ['(no options)']
     self.continuation_url = TestHostUri + entitydata_list_type_url(
         coll_id="testcoll", type_id="_list")
     # 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
コード例 #22
0
 def setUp(self):
     init_annalist_test_site()
     self.testsite = Site(TestBaseUri, TestBaseDir)
     self.testcoll = Collection.create(self.testsite, "testcoll", collection_create_values("testcoll"))
     # Login and permissions
     create_test_user(
         self.testsite.site_data_collection(),
         # self.testcoll, 
         "testuser", "testpassword",
         user_permissions=["VIEW", "CREATE", "UPDATE", "DELETE", "CONFIG", "ADMIN"]
         )
     self.client = Client(HTTP_HOST=TestHost)
     loggedin = self.client.login(username="******", password="******")
     self.assertTrue(loggedin)
     return
コード例 #23
0
ファイル: site.py プロジェクト: juandesant/annalist
    def add_collection(self, coll_id, coll_meta, annal_ver=annalist.__version_data__):
        """
        Add a new collection to the current site

        coll_id     identifier for the new collection, as a string
                    with a form that is valid as URI path segment.
        coll_meta   a dictionary providing additional information about
                    the collection to be created.
        annal_ver   Override annalist version stored in collection metadata
                    (parameter provided for testing)

        returns a Collection object for the newly created collection.
        """
        d = dict(coll_meta)
        d[ANNAL.CURIE.software_version] = annal_ver
        c = Collection.create(self, coll_id, d)
        return c
コード例 #24
0
 def setUp(self):
     init_annalist_test_site()
     self.imagename = "test-image.jpg"
     self.imagepath = "%s/%s"%(TestBaseDir, self.imagename)
     self.imageuri  = "file://"+self.imagepath
     self.testsite  = Site(TestBaseUri, TestBaseDir)
     self.testcoll  = Collection.create(self.testsite,     "testcoll", collection_create_values("testcoll"))
     self.img_type  = RecordType.create(self.testcoll,     "img_type", recordtype_create_values("img_type"))
     self.img_data  = RecordTypeData.create(self.testcoll, "img_type", {})
     self.ref_type  = RecordType.create(self.testcoll,     "ref_type", recordtype_create_values("ref_type"))
     self.ref_data  = RecordTypeData.create(self.testcoll, "ref_type", {})
     # 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
コード例 #25
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("testtype"))
     self.testdata = RecordTypeData.create(self.testcoll, "testtype", {})
     self.type_ids = get_site_types_sorted() + ['testtype']
     self.no_options = ['(no options)']
     # 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
 def setUp(self):
     init_annalist_test_site()
     init_annalist_test_coll()
     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("testtype"))
     self.testdata = RecordTypeData.create(self.testcoll, "testtype", {})
     self.no_options = [ FieldChoice('', label="(no options)") ]
     self.no_view_id = [ FieldChoice('', label="(view id)") ]
     self.no_list_id = [ FieldChoice('', label="(list id)") ]
     self.view_options = get_site_views_linked("testcoll")
     self.list_options = 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
コード例 #27
0
ファイル: test_recordvocab.py プロジェクト: gklyne/annalist
 def setUp(self):
     init_annalist_test_site()
     self.testsite   = Site(TestBaseUri, TestBaseDir)
     self.testcoll   = Collection.create(
         self.testsite, "testcoll", collection_create_values("testcoll")
         )
     self.annalcoll  = Collection.load(self.testsite, layout.SITEDATA_ID)
     self.no_options = [ FieldChoice('', label="(no options)") ]
     # For checking Location: header values...
     self.continuation_url = (
         entitydata_list_type_url(coll_id="testcoll", type_id=layout.VOCAB_TYPEID)
         )
     # Login and permissions
     create_test_user(self.testcoll, "testuser", "testpassword")
     create_user_permissions(self.annalcoll, "testuser", user_permissions=["VIEW"])
     self.client = Client(HTTP_HOST=TestHost)
     loggedin = self.client.login(username="******", password="******")
     self.assertTrue(loggedin)
     return
コード例 #28
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
コード例 #29
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
コード例 #30
0
 def setUp(self):
     init_annalist_test_site()
     self.testsite = Site(TestBaseUri, TestBaseDir)
     self.testcoll = Collection.create(
         self.testsite, "testcoll", collection_create_values("testcoll")
         )
     # For checking Location: header values...
     self.continuation_url = TestHostUri + entitydata_list_type_url(
         coll_id="testcoll", type_id=layout.USER_TYPEID
         )
     # Login and permissions
     create_test_user(
         self.testcoll, "testuser", "testpassword",
         user_permissions=["VIEW", "CREATE", "UPDATE", "DELETE", "CONFIG", "ADMIN"]
         )
     self.client = Client(HTTP_HOST=TestHost)
     loggedin = self.client.login(username="******", password="******")
     self.assertTrue(loggedin)
     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"))
     self.no_options = [ FieldChoice('', label="(no options)") ]
     self.no_view_id = [ FieldChoice('', label="(view id)") ]
     self.no_list_id = [ FieldChoice('', label="(list id)") ]
     self.view_options = self.no_view_id + get_site_views_linked("testcoll")
     self.list_options = self.no_list_id + get_site_lists_linked("testcoll")
     # For checking Location: header values...
     self.continuation_url = (
         TestHostUri + 
         entitydata_list_type_url(coll_id="testcoll", type_id=layout.TYPE_TYPEID)
         )
     # 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 setUp(self):
     init_annalist_test_site()
     self.testsite = Site(TestBaseUri, TestBaseDir)
     self.testcoll = Collection.create(self.testsite, "testcoll",
                                       collection_create_values("testcoll"))
     self.no_options = [FieldChoice('', label="(no options)")]
     self.no_view_id = [FieldChoice('', label="(view id)")]
     self.no_list_id = [FieldChoice('', label="(list id)")]
     self.view_options = self.no_view_id + get_site_views_linked("testcoll")
     self.list_options = self.no_list_id + get_site_lists_linked("testcoll")
     # For checking Location: header values...
     self.continuation_url = (TestHostUri + entitydata_list_type_url(
         coll_id="testcoll", type_id=layout.TYPE_TYPEID))
     # 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
コード例 #33
0
 def setUp(self):
     self.testsite = init_annalist_test_site()
     self.testcoll = Collection.create(self.testsite, "testcoll",
                                       collection_create_values("testcoll"))
     # Create test type
     self.testtypes = RecordType.create(
         self.testcoll, "testtype",
         recordtype_create_values(coll_id="testcoll",
                                  type_id="testtype",
                                  type_uri="test:testtype",
                                  supertype_uris=[]))
     # Create test type data parents
     self.testdata = RecordTypeData.create(self.testcoll, "testtype", {})
     # 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_empty_coll_data(site, coll_id, label=None, description=None):
     """
     Create empty collection, and returns the Collection object.
     """
     datetime_now = datetime.datetime.today().replace(microsecond=0)
     if label is None:
         label = "Collection %s" % coll_id
     if description is None:
         description = "Annalist data collection %s" % coll_id
     annal_comment = (
         "Initialized by annalist.models.site.create_empty_coll_data at " +
         datetime_now.isoformat(' '))
     coll_values = ({
         RDFS.CURIE.label: label,
         RDFS.CURIE.comment: description,
         ANNAL.CURIE.meta_comment: annal_comment,
         ANNAL.CURIE.software_version: annalist.__version_data__
     })
     coll = Collection.create(site, coll_id, coll_values)
     return coll
コード例 #35
0
    def add_collection(self,
                       coll_id,
                       coll_meta,
                       annal_ver=annalist.__version_data__):
        """
        Add a new collection to the current site

        coll_id     identifier for the new collection, as a string
                    with a form that is valid as URI path segment.
        coll_meta   a dictionary providing additional information about
                    the collection to be created.
        annal_ver   Override annalist version stored in collection metadata
                    (parameter provided for testing)

        returns a Collection object for the newly created collection.
        """
        d = dict(coll_meta)
        d[ANNAL.CURIE.software_version] = annal_ver
        c = Collection.create(self, coll_id, d)
        return c
コード例 #36
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
コード例 #37
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.annalcoll = Collection.load(self.testsite, layout.SITEDATA_ID)
     self.no_options = [FieldChoice('', label="(no options)")]
     # For checking Location: header values...
     self.continuation_url = (TestHostUri + entitydata_list_type_url(
         coll_id="testcoll", type_id=layout.VOCAB_TYPEID))
     # Login and permissions
     create_test_user(self.testcoll, "testuser", "testpassword")
     create_user_permissions(self.annalcoll,
                             "testuser",
                             user_permissions=["VIEW"])
     self.client = Client(HTTP_HOST=TestHost)
     loggedin = self.client.login(username="******",
                                  password="******")
     self.assertTrue(loggedin)
     return
コード例 #38
0
 def setUp(self):
     init_annalist_test_site()
     self.testsite = Site(TestBaseUri, TestBaseDir)
     self.testcoll = Collection.create(self.testsite, "testcoll",
                                       collection_create_values("testcoll"))
     # For checking Location: header values...
     self.continuation_url = TestHostUri + entitydata_list_type_url(
         coll_id="testcoll", type_id="_user")
     # Login and permissions
     create_test_user(self.testcoll,
                      "testuser",
                      "testpassword",
                      user_permissions=[
                          "VIEW", "CREATE", "UPDATE", "DELETE", "CONFIG",
                          "ADMIN"
                      ])
     self.client = Client(HTTP_HOST=TestHost)
     loggedin = self.client.login(username="******",
                                  password="******")
     self.assertTrue(loggedin)
     return
コード例 #39
0
 def setUp(self):
     self.testsite  = init_annalist_test_site()
     self.testcoll  = Collection.create(
         self.testsite, "testcoll", collection_create_values("testcoll")
         )
     # Create test type
     self.testtypes = RecordType.create(
         self.testcoll, "testtype", 
         recordtype_create_values(
             coll_id="testcoll", type_id="testtype", type_uri="test:testtype",
             supertype_uris=[]
             )
         )
     # Create test type data parents
     self.testdata = RecordTypeData.create(self.testcoll, "testtype", {})
     # 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
コード例 #40
0
 def setUp(self):
     init_annalist_test_site()
     init_annalist_test_coll()
     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("testtype"))
     self.testdata = RecordTypeData.create(self.testcoll, "testtype", {})
     self.no_options = [FieldChoice('', label="(no options)")]
     self.no_view_id = [FieldChoice('', label="(view id)")]
     self.no_list_id = [FieldChoice('', label="(list id)")]
     self.view_options = get_site_views_linked("testcoll")
     self.list_options = 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
コード例 #41
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("testtype"))
     # 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: ANNAL.CURIE.EntityData
         , 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
コード例 #42
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
コード例 #43
0
ファイル: site.py プロジェクト: juandesant/annalist
 def create_empty_coll_data(
     site, coll_id,
     label=None, description=None):
     """
     Create empty collection, and returns the Collection object.
     """
     datetime_now = datetime.datetime.today().replace(microsecond=0)
     if label is None:
         label = "Collection %s"%coll_id
     if description is None:
         description = "Annalist data collection %s"%coll_id
     annal_comment = (
         "Initialized by annalist.models.site.create_empty_coll_data at "+
         datetime_now.isoformat(' ')
         )
     coll_values = (
         { RDFS.CURIE.label:             label
         , RDFS.CURIE.comment:           description
         , ANNAL.CURIE.meta_comment:     annal_comment                                    
         , ANNAL.CURIE.software_version: annalist.__version_data__
         })
     coll = Collection.create(site, coll_id, coll_values)
     return coll
コード例 #44
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
コード例 #45
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.no_options = ['(no options)']
     self.view_options = sorted([
         vid for vid in self.testcoll.child_entity_ids(
             RecordView, self.testsite) if vid != "_initial_values"
     ])
     self.list_options = sorted([
         lid for lid in self.testcoll.child_entity_ids(
             RecordList, self.testsite) if lid != "_initial_values"
     ])
     # For checking Location: header values...
     self.continuation_url = TestHostUri + entitydata_list_type_url(
         coll_id="testcoll", type_id="_type")
     # 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
コード例 #46
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