Beispiel #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
Beispiel #2
0
 def setUp(self):
     init_annalist_test_site()
     self.testsite    = Site(TestBaseUri, TestBaseDir)
     self.coll1       = collection_values(coll_id="coll1")
     self.collnewmeta = collection_create_values(coll_id="new")
     self.collnew     = collection_values(coll_id="new")
     return
    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
Beispiel #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
Beispiel #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
    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
 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
 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
 def test_get_view_newer_version(self):
     collmeta = collection_create_values(coll_id="newer_version")
     self.testsite.add_collection("newer_version", collmeta, annal_ver="99.99.99")
     u = collection_view_url(coll_id="newer_version")
     r = self.client.get(u)
     self.assertEqual(r.status_code,   500)
     self.assertEqual(r.reason_phrase, "Server error")
     self.assertContains(r, "created by software version 99.99.99", status_code=500)
     return
Beispiel #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
 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
 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
Beispiel #13
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
 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
 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
 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
 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
 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
 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
Beispiel #20
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
Beispiel #21
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
 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
 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
 def setUp(self):
     init_annalist_test_site()
     self.testsite = Site(TestBaseUri, TestBaseDir)
     self.testcoll = Collection(self.testsite, "testcoll")
     self.coll1 = collection_values("coll1")
     self.testcoll_add = collection_create_values("testcoll")
     self.type1_add = recordtype_create_values("testcoll", "type1")
     self.type1 = recordtype_read_values("testcoll", "type1")
     self.type2_add = recordtype_create_values("testcoll", "type2")
     self.type2 = recordtype_read_values("testcoll", "type2")
     self.view1_add = recordview_create_values("testcoll", "view1")
     self.view1 = recordview_read_values("testcoll", "view1")
     self.view2_add = recordview_create_values("testcoll", "view2")
     self.view2 = recordview_read_values("testcoll", "view2")
     self.list1_add = recordlist_create_values("testcoll", "list1")
     self.list1 = recordlist_read_values("testcoll", "list1")
     self.list2_add = recordlist_create_values("testcoll", "list2")
     self.list2 = recordlist_read_values("testcoll", "list2")
     return
 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
Beispiel #26
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
 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
Beispiel #28
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
 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
Beispiel #30
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
Beispiel #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.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
Beispiel #32
0
 def setUp(self):
     init_annalist_test_site()
     init_annalist_test_coll()
     self.testsite     = Site(TestBaseUri, TestBaseDir)
     self.testcoll     = Collection(self.testsite, "testcoll")
     self.coll1        = collection_values("coll1")
     self.testcoll_add = collection_create_values("testcoll")
     self.type1_add    = recordtype_create_values("testcoll", "type1")
     self.type1        = recordtype_read_values("testcoll", "type1")
     self.type2_add    = recordtype_create_values("testcoll", "type2")
     self.type2        = recordtype_read_values("testcoll", "type2")
     self.view1_add    = recordview_create_values("testcoll", "view1")
     self.view1        = recordview_read_values("testcoll", "view1")
     self.view2_add    = recordview_create_values("testcoll", "view2")
     self.view2        = recordview_read_values("testcoll", "view2")
     self.list1_add    = recordlist_create_values("testcoll", "list1")
     self.list1        = recordlist_read_values("testcoll", "list1")
     self.list2_add    = recordlist_create_values("testcoll", "list2")
     self.list2        = recordlist_read_values("testcoll", "list2")
     return
Beispiel #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
 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
 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
 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
 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
Beispiel #38
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
Beispiel #39
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
Beispiel #40
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
Beispiel #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"))
     # 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
 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