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
Beispiel #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
 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
 def setUp(self):
     init_annalist_test_site()
     init_annalist_test_coll()
     self.testsite    = Site(TestBaseUri, TestBaseDir)
     self.testcoll    = Collection(self.testsite, "testcoll")
     # Populate collection with linked record types, views and lists
     self.testsrc_type = RecordType.create(self.testcoll, "testsrc_type", testsrc_type_create_values)
     self.testtgt_type = RecordType.create(self.testcoll, "testtgt_type", testtgt_type_create_values)
     self.testsrc_view = RecordView.create(self.testcoll, "testsrc_view", testsrc_view_create_values)
     self.testtgt_view = RecordView.create(self.testcoll, "testtgt_view", testtgt_view_create_values)
     self.testsrc_list = RecordList.create(self.testcoll, "testsrc_list", testsrc_list_create_values)
     self.testtgt_list = RecordList.create(self.testcoll, "testtgt_list", testtgt_list_create_values)
     self.testtgtref_field = RecordField.create(self.testcoll, "testtgtref_field", testtgtref_field_create_values)
     self.no_options   = [ FieldChoice('', label="(no options)") ]
     self.tgt_options  = (
         [ FieldChoice("testtgt_type/"+v, 
             label="testtgt_entity %s label"%v,
             link=entity_url("testcoll", "testtgt_type", v))
           for v in ["testtgt1", "testtgt2"]
         ])
     # Create data records for testing:
     self.testtgt_type_info = EntityTypeInfo(self.testcoll, "testtgt_type", create_typedata=True)
     self.testsrc_type_info = EntityTypeInfo(self.testcoll, "testsrc_type", create_typedata=True)
     for tgt_id in ("testtgt1", "testtgt2"):
         self.testtgt_type_info.create_entity(tgt_id, testtgt_entity_create_values(tgt_id))
     for src_id, tgt_ref in (("testsrc1", "testtgt1"), ("testsrc2", "testtgt2")):
         self.testsrc_type_info.create_entity(src_id, testsrc_entity_create_values(src_id, tgt_ref))
     # Login and permissions
     create_test_user(self.testcoll, "testuser", "testpassword")
     self.client = Client(HTTP_HOST=TestHost)
     loggedin = self.client.login(username="******", password="******")
     self.assertTrue(loggedin)
     return
Beispiel #5
0
 def setUp(self):
     init_annalist_test_site()
     init_annalist_test_coll()
     self.testsite = Site(TestBaseUri, TestBaseDir)
     self.testcoll = Collection(self.testsite, "testcoll")
     # Populate collection with linked record types, views and lists
     self.test_supertype_type = RecordType.create(
         self.testcoll, "test_supertype_type",
         test_supertype_type_create_values)
     self.test_subtype_type = RecordType.create(
         self.testcoll, "test_subtype_type",
         test_subtype_type_create_values)
     self.no_options = [FieldChoice('', label="(no options)")]
     # Create type and data records for testing:
     self.test_supertype_type_info = EntityTypeInfo(self.testcoll,
                                                    "test_supertype_type",
                                                    create_typedata=True)
     self.test_subtype_type_info = EntityTypeInfo(self.testcoll,
                                                  "test_subtype_type",
                                                  create_typedata=True)
     for entity_id in ("test_subtype_entity", ):
         self.test_subtype_type_info.create_entity(
             entity_id, test_subtype_entity_create_values(entity_id))
     # Login and permissions
     create_test_user(self.testcoll, "testuser", "testpassword")
     self.client = Client(HTTP_HOST=TestHost)
     loggedin = self.client.login(username="******",
                                  password="******")
     self.assertTrue(loggedin)
     return
 def setUp(self):
     init_annalist_test_site()
     init_annalist_test_coll()
     self.testsite = Site(TestBaseUri, TestBaseDir)
     self.testcoll = Collection(self.testsite, "testcoll")
     # Populate collection with linked record types, views and lists
     self.testsrc_type = RecordType.create(self.testcoll, "testsrc_type",
                                           testsrc_type_create_values)
     self.testtgt_type = RecordType.create(self.testcoll, "testtgt_type",
                                           testtgt_type_create_values)
     self.testsrc_view = RecordView.create(self.testcoll, "testsrc_view",
                                           testsrc_view_create_values)
     self.testtgt_view = RecordView.create(self.testcoll, "testtgt_view",
                                           testtgt_view_create_values)
     self.testsrc_list = RecordList.create(self.testcoll, "testsrc_list",
                                           testsrc_list_create_values)
     self.testtgt_list = RecordList.create(self.testcoll, "testtgt_list",
                                           testtgt_list_create_values)
     self.testtgtref_field = RecordField.create(
         self.testcoll, "testtgtref_field", testtgtref_field_create_values)
     self.no_options = [FieldChoice('', label="(no options)")]
     self.tgt_options = ([
         FieldChoice("testtgt_type/" + v,
                     label="testtgt_entity %s label" % v,
                     link=entity_url("testcoll", "testtgt_type", v))
         for v in ["testtgt1", "testtgt2"]
     ])
     # Create data records for testing:
     self.testtgt_type_info = EntityTypeInfo(self.testcoll,
                                             "testtgt_type",
                                             create_typedata=True)
     self.testsrc_type_info = EntityTypeInfo(self.testcoll,
                                             "testsrc_type",
                                             create_typedata=True)
     for tgt_id in ("testtgt1", "testtgt2"):
         self.testtgt_type_info.create_entity(
             tgt_id, testtgt_entity_create_values(tgt_id))
     for src_id, tgt_ref in (("testsrc1", "testtgt1"), ("testsrc2",
                                                        "testtgt2")):
         self.testsrc_type_info.create_entity(
             src_id, testsrc_entity_create_values(src_id, tgt_ref))
     # Login and permissions
     create_test_user(self.testcoll, "testuser", "testpassword")
     self.client = Client(HTTP_HOST=TestHost)
     loggedin = self.client.login(username="******",
                                  password="******")
     self.assertTrue(loggedin)
     return
 def test_post_edit_entity_new_type(self):
     self._create_entity_data("entityedittype")
     e1 = self._check_entity_data_values("entityedittype")
     self.assertFalse(RecordType.exists(self.testcoll, "newtype"))
     newtype     = RecordType.create(self.testcoll, "newtype", recordtype_create_values("newtype"))
     newtypedata = RecordTypeData(self.testcoll, "newtype")
     self.assertTrue(RecordType.exists(self.testcoll, "newtype"))
     self.assertFalse(RecordTypeData.exists(self.testcoll, "newtype"))
     # Now post edit form submission with new type id
     f = default_view_form_data(
         entity_id="entityedittype", orig_id="entityedittype", 
         type_id="newtype", orig_type="testtype",
         action="edit")
     u = entitydata_edit_url("edit", "testcoll", "testtype", entity_id="entityedittype")
     r = self.client.post(u, f)
     # log.info("***********\n"+r.content)
     self.assertEqual(r.status_code,   302)
     self.assertEqual(r.reason_phrase, "Found")
     self.assertEqual(r.content,       b"")
     self.assertEqual(r['location'],   entitydata_list_type_url("testcoll", "testtype"))
     # Check that new record type data now exists, and that new record exists and old does not
     self.assertTrue(RecordTypeData.exists(self.testcoll, "newtype"))
     self.assertFalse(EntityData.exists(self.testdata, "entityedittype"))
     self.assertTrue(EntityData.exists(newtypedata, "entityedittype"))
     self._check_entity_data_values("entityedittype", type_id="newtype")
     return
Beispiel #8
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)
Beispiel #9
0
 def test_recordtype_create_load(self):
     t  = RecordType.create(self.testcoll, "type1", recordtype_create_values(type_id="type1"))
     td = RecordType.load(self.testcoll, "type1").get_values()
     v  = recordtype_read_values(type_id="type1")
     self.assertKeysMatch(td, v)
     self.assertDictionaryMatch(td, v)
     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 #11
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 #12
0
 def setUp(self):
     self.filepath  = "%s/README.md"%TestBaseDir
     self.fileuri   = "file://"+self.filepath
     self.imagepath = "%s/test-image.jpg"%TestBaseDir
     self.imageuri  = "file://"+self.filepath
     init_annalist_test_site()
     init_annalist_test_coll()
     self.testsite    = Site(TestBaseUri, TestBaseDir)
     self.testcoll    = Collection(self.testsite, "testcoll")
     # Populate collection with record type, view and field
     self.test_ref_type = RecordType.create(
         self.testcoll, "testreftype", test_image_ref_type_create_values
         )
     self.test_ref_view = RecordView.create(
         self.testcoll, "testrefview", test_image_ref_view_create_values
         )
     self.test_ref_field = RecordField.create(
         self.testcoll, "Test_image_ref", test_image_ref_field_create_values
         )
     # Create data records for testing image references:
     self.test_ref_type_info = EntityTypeInfo(
         self.testcoll, "testreftype", create_typedata=True
         )
     self.test_ref_type_info.create_entity("test1", test_ref_entity_create_values(self.imageuri))
     # Login and permissions
     create_test_user(self.testcoll, "testuser", "testpassword")
     self.client = Client(HTTP_HOST=TestHost)
     loggedin = self.client.login(username="******", password="******")
     self.assertTrue(loggedin)
     return
    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 #14
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 #15
0
 def test_post_edit_entity_new_type(self):
     self._create_entity_data("entityedittype")
     e1 = self._check_entity_data_values("entityedittype")
     self.assertFalse(RecordType.exists(self.testcoll, "newtype"))
     newtype = RecordType.create(self.testcoll, "newtype",
                                 recordtype_create_values("newtype"))
     newtypedata = RecordTypeData(self.testcoll, "newtype")
     self.assertTrue(RecordType.exists(self.testcoll, "newtype"))
     self.assertFalse(RecordTypeData.exists(self.testcoll, "newtype"))
     # Now post edit form submission with new type id
     f = entitydata_form_data(entity_id="entityedittype",
                              orig_id="entityedittype",
                              type_id="newtype",
                              orig_type="testtype",
                              action="edit")
     u = entitydata_edit_url("edit",
                             "testcoll",
                             "testtype",
                             entity_id="entityedittype")
     r = self.client.post(u, f)
     # log.info("***********\n"+r.content)
     self.assertEqual(r.status_code, 302)
     self.assertEqual(r.reason_phrase, "FOUND")
     self.assertEqual(r.content, "")
     self.assertEqual(
         r['location'],
         TestHostUri + entitydata_list_type_url("testcoll", "testtype"))
     # Check that new record type data now exists, and that new record exists and old does not
     self.assertTrue(RecordTypeData.exists(self.testcoll, "newtype"))
     self.assertFalse(EntityData.exists(self.testdata, "entityedittype"))
     self.assertTrue(EntityData.exists(newtypedata, "entityedittype"))
     self._check_entity_data_values("entityedittype", type_id="newtype")
     return
Beispiel #16
0
 def setUp(self):
     self.filepath  = "%s/README.md"%TestBaseDir
     self.fileuri   = "file://"+self.filepath
     self.imagepath = "%s/test-image.jpg"%TestBaseDir
     self.imageuri  = "file://"+self.filepath
     init_annalist_test_site()
     init_annalist_test_coll()
     self.testsite    = Site(TestBaseUri, TestBaseDir)
     self.testcoll    = Collection(self.testsite, "testcoll")
     # Populate collection with record type, view and field
     self.test_ref_type = RecordType.create(
         self.testcoll, "testreftype", test_image_ref_type_create_values
         )
     self.test_ref_view = RecordView.create(
         self.testcoll, "testrefview", test_image_ref_view_create_values
         )
     self.test_ref_field = RecordField.create(
         self.testcoll, "Test_image_ref", test_image_ref_field_create_values
         )
     # Create data records for testing image references:
     self.test_ref_type_info = EntityTypeInfo(
         self.testcoll, "testreftype", create_typedata=True
         )
     self.test_ref_type_info.create_entity("test1", test_ref_entity_create_values(self.imageuri))
     # Login and permissions
     create_test_user(self.testcoll, "testuser", "testpassword")
     self.client = Client(HTTP_HOST=TestHost)
     loggedin = self.client.login(username="******", password="******")
     self.assertTrue(loggedin)
     return
 def test_post_delete_type_entity(self):
     testtypedelete = RecordType.create(self.testcoll, "testtypedelete", recordtype_create_values("testcoll", "testtypedelete"))
     testdatadelete = RecordTypeData.create(self.testcoll, "testtypedelete", {})
     f = entitylist_form_data("delete", entities=["_type/testtypedelete"])
     u = entitydata_list_type_url("testcoll", "_type", list_id="Type_list")
     r = self.client.post(u, f)
     self.assertEqual(r.status_code,   200)
     self.assertEqual(r.reason_phrase, "OK")
     self.assertContains(r, "<h3>Confirm requested action</h3>")
     self.assertContains(r, "Remove record testtypedelete of type _type in collection testcoll: Are you sure?")
     self.assertContains(r, 'Click "Confirm" to continue, or "Cancel" to abort operation')
     self.assertContains(r,
         '<input type="hidden" name="confirmed_action"  value="/testsite/c/testcoll/d/_type/!delete_confirmed"/>', 
         html=True
         )
     self.assertEqual(r.context['action_description'], 
         'Remove record testtypedelete of type _type in collection testcoll')
     self.assertEqual(r.context['confirmed_action'], 
         '/testsite/c/testcoll/d/_type/!delete_confirmed')
     self.assertEqual(r.context['action_params'], 
         confirm_delete_params(button_id="entity_delete", entity_id="testtypedelete", type_id="_type", list_id="Type_list")
         )
     self.assertEqual(r.context['cancel_action'], 
         '/testsite/c/testcoll/l/Type_list/_type/')
     return
Beispiel #18
0
 def test_recordtype_create_load(self):
     t = RecordType.create(self.testcoll, "type1",
                           recordtype_create_values(type_id="type1"))
     td = RecordType.load(self.testcoll, "type1").get_values()
     v = recordtype_read_values(type_id="type1")
     self.assertKeysMatch(td, v)
     self.assertDictionaryMatch(td, v)
     return
Beispiel #19
0
 def setUp(self):
     self.fileuri = "file://%s/README.md"%TestBaseDir
     init_annalist_test_site()
     init_annalist_test_coll()
     self.testsite    = Site(TestBaseUri, TestBaseDir)
     self.testcoll    = Collection(self.testsite, "testcoll")
     # Populate collection with linked record types, views and lists
     self.test_imp_type = RecordType.create(
         self.testcoll, "testimptype", test_import_type_create_values
         )
     self.test_imp_view = RecordView.create(
         self.testcoll, "testimpview", test_import_view_create_values
         )
     self.test_imp_field = RecordField.create(
         self.testcoll, "Test_import", test_import_field_create_values
         )
     self.test_ref_type = RecordType.create(
         self.testcoll, "testreftype", test_reference_type_create_values
         )
     self.test_ref_view = RecordView.create(
         self.testcoll, "testrefview", test_reference_view_create_values
         )
     self.test_ref_field = RecordField.create(
         self.testcoll, "Test_reference", test_reference_field_create_values
         )
     # Create data records for testing import and references:
     self.test_imp_type_info = EntityTypeInfo(
         self.testcoll, "testimptype", create_typedata=True
         )
     for entity_id in ("test1", "test2"):
         self.test_imp_type_info.create_entity(
             entity_id, test_imp_entity_create_values(entity_id)
             )
     self.test_ref_type_info = EntityTypeInfo(
         self.testcoll, "testreftype", create_typedata=True
         )
     for entity_id in ("test1", "test2"):
         self.test_ref_type_info.create_entity(
             entity_id, test_ref_entity_create_values(entity_id)
             )
     # Login and permissions
     create_test_user(self.testcoll, "testuser", "testpassword")
     self.client = Client(HTTP_HOST=TestHost)
     loggedin = self.client.login(username="******", password="******")
     self.assertTrue(loggedin)
     return
Beispiel #20
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):
     self.fileuri = "file://%s/README.md"%TestBaseDir
     init_annalist_test_site()
     init_annalist_test_coll()
     self.testsite    = Site(TestBaseUri, TestBaseDir)
     self.testcoll    = Collection(self.testsite, "testcoll")
     # Populate collection with linked record types, views and lists
     self.test_imp_type = RecordType.create(
         self.testcoll, "testimptype", test_import_type_create_values
         )
     self.test_imp_view = RecordView.create(
         self.testcoll, "testimpview", test_import_view_create_values
         )
     self.test_imp_field = RecordField.create(
         self.testcoll, "Test_import", test_import_field_create_values
         )
     self.test_ref_type = RecordType.create(
         self.testcoll, "testreftype", test_reference_type_create_values
         )
     self.test_ref_view = RecordView.create(
         self.testcoll, "testrefview", test_reference_view_create_values
         )
     self.test_ref_field = RecordField.create(
         self.testcoll, "Test_reference", test_reference_field_create_values
         )
     # Create data records for testing import and references:
     self.test_imp_type_info = EntityTypeInfo(
         self.testcoll, "testimptype", create_typedata=True
         )
     for entity_id in ("test1", "test2"):
         self.test_imp_type_info.create_entity(
             entity_id, test_imp_entity_create_values(entity_id)
             )
     self.test_ref_type_info = EntityTypeInfo(
         self.testcoll, "testreftype", create_typedata=True
         )
     for entity_id in ("test1", "test2"):
         self.test_ref_type_info.create_entity(
             entity_id, test_ref_entity_create_values(entity_id)
             )
     # Login and permissions
     create_test_user(self.testcoll, "testuser", "testpassword")
     self.client = Client(HTTP_HOST=TestHost)
     loggedin = self.client.login(username="******", password="******")
     self.assertTrue(loggedin)
     return
Beispiel #22
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 #23
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", {})

        # 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.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 #26
0
    def add_type(self, type_id, type_meta):
        """
        Add a new record type to the current collection

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

        returns a RecordType object for the newly created type.
        """
        t = RecordType.create(self, type_id, type_meta)
        return t
Beispiel #27
0
    def add_type(self, type_id, type_meta):
        """
        Add a new or updated record type to the current collection

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

        Returns a RecordType object for the newly created type.
        """
        log.debug("Collection.add_type %s in %s"%(type_id, self.get_id()))
        t = RecordType.create(self, type_id, type_meta)
        return t
Beispiel #28
0
    def add_type(self, type_id, type_meta):
        """
        Add a new or updated record type to the current collection

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

        Returns a RecordType object for the newly created type.
        """
        log.debug("Collection.add_type %s in %s"%(type_id, self.get_id()))
        t = RecordType.create(self, type_id, type_meta)
        return t
Beispiel #29
0
    def add_type(self, type_id, type_meta):
        """
        Add a new record type to the current collection

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

        Returns a RecordType object for the newly created type.
        """
        t = RecordType.create(self, type_id, type_meta)
        if self._types_by_id:
            self._update_type_cache(t)
        return t
 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
Beispiel #31
0
 def test_post_confirmed_remove_type(self):
     t = RecordType.create(self.testcoll, "deletetype",
                           recordtype_create_values("deletetype"))
     self.assertTrue(RecordType.exists(self.testcoll, "deletetype"))
     # Submit positive confirmation
     u = TestHostUri + recordtype_edit_url("delete", "testcoll")
     f = recordtype_delete_confirm_form_data("deletetype")
     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 + collection_edit_url("testcoll") +
         r"\?info_head=.*&info_message=.*deletetype.*testcoll.*$")
     # Confirm deletion
     self.assertFalse(RecordType.exists(self.testcoll, "deletetype"))
     return
Beispiel #32
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 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 #34
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):
     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
Beispiel #36
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
Beispiel #37
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
 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):
     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
Beispiel #40
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 #41
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 #42
0
 def test_post_confirmed_remove_type(self):
     t = RecordType.create(self.testcoll, "deletetype", recordtype_create_values("deletetype"))
     self.assertTrue(RecordType.exists(self.testcoll, "deletetype"))
     # Submit positive confirmation
     u = TestHostUri + recordtype_edit_url("delete", "testcoll")
     f = recordtype_delete_confirm_form_data("deletetype")
     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+
         collection_edit_url("testcoll")+
         r"\?.*info_head=.*$"
         )
     self.assertMatch(r['location'],    
         "^"+TestHostUri+
         collection_edit_url("testcoll")+
         r"\?.*info_message=.*deletetype.*testcoll.*$"
         )
     # Confirm deletion
     self.assertFalse(RecordType.exists(self.testcoll, "deletetype"))
     return
Beispiel #43
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
Beispiel #44
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)
Beispiel #45
0
    def setUp(self):
        self.filepath  = "%s/testdatafile.md"%TestBaseDir
        self.fileuri   = "file://"+self.filepath
        self.imagepath = "%s/test-image.jpg"%TestBaseDir
        self.imageuri  = "file://"+self.imagepath
        init_annalist_test_site()
        init_annalist_test_coll()
        self.testsite  = Site(TestBaseUri, TestBaseDir)
        self.testcoll  = Collection(self.testsite, "testcoll")
        # Populate collection with linked record types, views and lists

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

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

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

        # Create data records for testing import and references:
        test_entity_ids = ("test1", "test2")
        test_entity_ids = ("test1",)
        self.test_upl_type_info = EntityTypeInfo(
            self.testcoll, "testupltype", create_typedata=True
            )
        for entity_id in test_entity_ids:
            self.test_upl_type_info.create_entity(
                entity_id, test_imp_entity_create_values(entity_id)
                )
        self.test_ref_type_info = EntityTypeInfo(
            self.testcoll, "testreftype", create_typedata=True
            )
        for entity_id in test_entity_ids:
            self.test_ref_type_info.create_entity(
                entity_id, test_ref_entity_create_values(entity_id)
                )
        self.test_img_type_info = EntityTypeInfo(
            self.testcoll, "testimgtype", create_typedata=True
            )
        for entity_id in test_entity_ids:
            self.test_img_type_info.create_entity(
                entity_id, test_img_entity_create_values(entity_id)
                )
        # Login and permissions
        create_test_user(self.testcoll, "testuser", "testpassword")
        self.client = Client(HTTP_HOST=TestHost)
        loggedin = self.client.login(username="******", password="******")
        self.assertTrue(loggedin)
        return
 def 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):
        self.filepath = "%s/testdatafile.md" % TestBaseDir
        self.fileuri = "file://" + self.filepath
        self.imagepath = "%s/test-image.jpg" % TestBaseDir
        self.imageuri = "file://" + self.imagepath
        init_annalist_test_site()
        init_annalist_test_coll()
        self.testsite = Site(TestBaseUri, TestBaseDir)
        self.testcoll = Collection(self.testsite, "testcoll")
        # Populate collection with linked record types, views and lists

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

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

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

        # Create data records for testing import and references:
        test_entity_ids = ("test1", "test2")
        test_entity_ids = ("test1", )
        self.test_upl_type_info = EntityTypeInfo(self.testcoll,
                                                 "testupltype",
                                                 create_typedata=True)
        for entity_id in test_entity_ids:
            self.test_upl_type_info.create_entity(
                entity_id, test_imp_entity_create_values(entity_id))
        self.test_ref_type_info = EntityTypeInfo(self.testcoll,
                                                 "testreftype",
                                                 create_typedata=True)
        for entity_id in test_entity_ids:
            self.test_ref_type_info.create_entity(
                entity_id, test_ref_entity_create_values(entity_id))
        self.test_img_type_info = EntityTypeInfo(self.testcoll,
                                                 "testimgtype",
                                                 create_typedata=True)
        for entity_id in test_entity_ids:
            self.test_img_type_info.create_entity(
                entity_id, test_img_entity_create_values(entity_id))
        # Login and permissions
        create_test_user(self.testcoll, "testuser", "testpassword")
        self.client = Client(HTTP_HOST=TestHost)
        loggedin = self.client.login(username="******",
                                     password="******")
        self.assertTrue(loggedin)
        return
 def create_type(self, type_id):
     # Create placeholder for testing
     t = RecordType.create(
         self.testcoll, type_id,
         recordtype_create_values(coll_id="testcoll", type_id="testtype"))
     return t
 def create_type_record(self, coll, type_entity):
     return RecordType.create(coll, type_entity.get_id(), type_entity.get_values())
 def create_type_record(self, coll, type_entity):
     return RecordType.create(coll, type_entity.get_id(),
                              type_entity.get_values())