本文整理汇总了Python中annalist.models.entitydata.EntityData.exists方法的典型用法代码示例。如果您正苦于以下问题:Python EntityData.exists方法的具体用法?Python EntityData.exists怎么用?Python EntityData.exists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类annalist.models.entitydata.EntityData
的用法示例。
在下文中一共展示了EntityData.exists方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_post_edit_type_new_id
# 需要导入模块: from annalist.models.entitydata import EntityData [as 别名]
# 或者: from annalist.models.entitydata.EntityData import exists [as 别名]
def test_post_edit_type_new_id(self):
# Check logic applied when type is renamed
(t, d1, e1) = self._create_record_type("edittype1", entity_id="typeentity")
self.assertTrue(RecordType.exists(self.testcoll, "edittype1"))
self.assertFalse(RecordType.exists(self.testcoll, "edittype2"))
self.assertTrue(RecordTypeData.exists(self.testcoll, "edittype1"))
self.assertFalse(RecordTypeData.exists(self.testcoll, "edittype2"))
self.assertTrue(EntityData.exists(d1, "typeentity"))
self._check_record_type_values("edittype1")
f = recordtype_entity_view_form_data(
type_id="edittype2", orig_id="edittype1",
action="edit", update="Updated RecordType"
)
u = entitydata_edit_url(
"edit", "testcoll", layout.TYPE_TYPEID, entity_id="edittype1", view_id="Type_view"
)
r = self.client.post(u, f)
self.assertEqual(r.status_code, 302)
self.assertEqual(r.reason_phrase, "FOUND")
self.assertEqual(r.content, "")
self.assertEqual(r['location'], self.continuation_url)
# Check that new record type exists and old does not
self.assertFalse(RecordType.exists(self.testcoll, "edittype1"))
self.assertTrue(RecordType.exists(self.testcoll, "edittype2"))
self._check_record_type_values("edittype2", update="Updated RecordType")
# Check that type data directory has been renamed
self.assertFalse(RecordTypeData.exists(self.testcoll, "edittype1"))
self.assertTrue(RecordTypeData.exists(self.testcoll, "edittype2"))
self.assertFalse(EntityData.exists(d1, "typeentity"))
d2 = RecordTypeData.load(self.testcoll, "edittype2")
self.assertTrue(EntityData.exists(d2, "typeentity"))
return
示例2: test_post_edit_entity_new_type
# 需要导入模块: from annalist.models.entitydata import EntityData [as 别名]
# 或者: from annalist.models.entitydata.EntityData import exists [as 别名]
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
示例3: test_post_copy_entity_cancel
# 需要导入模块: from annalist.models.entitydata import EntityData [as 别名]
# 或者: from annalist.models.entitydata.EntityData import exists [as 别名]
def test_post_copy_entity_cancel(self):
self.assertFalse(EntityData.exists(self.testdata, "copytype"))
f = default_view_form_data(entity_id="copytype", action="copy", cancel="Cancel")
u = entitydata_edit_url("copy", "testcoll", "testtype", entity_id="entity1")
r = self.client.post(u, f)
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 target record type still does not exist
self.assertFalse(EntityData.exists(self.testdata, "copytype"))
return
示例4: test_new_entity_new_type
# 需要导入模块: from annalist.models.entitydata import EntityData [as 别名]
# 或者: from annalist.models.entitydata.EntityData import exists [as 别名]
def test_new_entity_new_type(self):
# Checks logic for creating an entity which may require creation of new recorddata
# Create new type
self.assertFalse(RecordType.exists(self.testcoll, "newtype"))
f = type_view_form_data(action="new",
coll_id="testcoll",
type_entity_id="newtype",
)
u = entitydata_edit_url("new", "testcoll", type_id="_type", view_id="Type_view")
r = self.client.post(u, f)
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", "_type"))
self.assertTrue(RecordType.exists(self.testcoll, "newtype"))
# Create new entity
self.assertFalse(EntityData.exists(self.testdata, "newentity"))
f = default_view_form_data(entity_id="newentity", type_id="newtype", action="new")
u = entitydata_edit_url("new", "testcoll", "newtype", view_id="Default_view")
r = self.client.post(u, f)
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", "newtype"))
# Check new entity data created
self._check_entity_data_values("newentity", type_id="newtype")
return
示例5: test_post_confirmed_remove_entity
# 需要导入模块: from annalist.models.entitydata import EntityData [as 别名]
# 或者: from annalist.models.entitydata.EntityData import exists [as 别名]
def test_post_confirmed_remove_entity(self):
t = EntityData.create(self.testdata, "deleteentity", entitydata_create_values("deleteentity"))
self.assertTrue(EntityData.exists(self.testdata, "deleteentity"))
# Submit positive confirmation
u = entitydata_delete_confirm_url("testcoll", "testtype")
f = entitydata_delete_confirm_form_data("deleteentity")
r = self.client.post(u, f)
self.assertEqual(r.status_code, 302)
self.assertEqual(r.reason_phrase, "Found")
self.assertEqual(r.content, b"")
v = entitydata_list_all_url("testcoll")
self.assertIn(v, r['location'])
self.assertIn("info_head=", r['location'])
self.assertIn("info_message=", r['location'])
self.assertNotIn("search=testcoll", r['location'])
# Confirm deletion
self.assertFalse(EntityData.exists(self.testcoll, "deleteentity"))
return
示例6: test_post_new_entity
# 需要导入模块: from annalist.models.entitydata import EntityData [as 别名]
# 或者: from annalist.models.entitydata.EntityData import exists [as 别名]
def test_post_new_entity(self):
self.assertFalse(EntityData.exists(self.testdata, "newentity"))
f = default_view_form_data(entity_id="newentity", action="new")
u = entitydata_edit_url("new", "testcoll", "testtype", view_id="Default_view")
r = self.client.post(u, f)
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 new entity data created
self._check_entity_data_values("newentity")
return
示例7: test_post_edit_entity_new_id
# 需要导入模块: from annalist.models.entitydata import EntityData [as 别名]
# 或者: from annalist.models.entitydata.EntityData import exists [as 别名]
def test_post_edit_entity_new_id(self):
self._create_entity_data("entityeditid1")
e1 = self._check_entity_data_values("entityeditid1")
# Now post edit form submission with different values and new id
f = default_view_form_data(entity_id="entityeditid2", orig_id="entityeditid1", action="edit")
u = entitydata_edit_url("edit", "testcoll", "testtype", entity_id="entityeditid1")
r = self.client.post(u, f)
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 exists and old does not
self.assertFalse(EntityData.exists(self.testdata, "entityeditid1"))
self._check_entity_data_values("entityeditid2")
return
示例8: test_post_confirmed_remove_entity_from_search
# 需要导入模块: from annalist.models.entitydata import EntityData [as 别名]
# 或者: from annalist.models.entitydata.EntityData import exists [as 别名]
def test_post_confirmed_remove_entity_from_search(self):
t = EntityData.create(self.testdata, "deleteentity", entitydata_create_values("deleteentity"))
self.assertTrue(EntityData.exists(self.testdata, "deleteentity"))
# Submit positive confirmation
u = entitydata_delete_confirm_url("testcoll", "testtype")
f = entitydata_delete_confirm_form_data("deleteentity", search="testcoll")
r = self.client.post(u, f)
self.assertEqual(r.status_code, 302)
self.assertEqual(r.reason_phrase, "FOUND")
self.assertEqual(r.content, "")
self.assertMatch(r['location'],
"^"+TestHostUri+
entitydata_list_all_url("testcoll")
)
self.assertMatch(r['location'],
r"info_head=.*$"
)
self.assertMatch(r['location'],
r"info_message=.*deleteentity.*testcoll.*$"
)
self.assertIn("search=testcoll", r['location'])
# Confirm deletion
self.assertFalse(EntityData.exists(self.testcoll, "deleteentity"))
return
示例9: test_new_entity_default_type
# 需要导入模块: from annalist.models.entitydata import EntityData [as 别名]
# 或者: from annalist.models.entitydata.EntityData import exists [as 别名]
def test_new_entity_default_type(self):
# Checks logic related to creating a new recorddata entity in collection
# for type defined in site data
self.assertFalse(EntityData.exists(self.testdata, "newentity"))
f = default_view_form_data(entity_id="newentity", type_id="Default_type", action="new")
u = entitydata_edit_url("new", "testcoll", "Default_type", view_id="Default_view")
r = self.client.post(u, f)
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", "Default_type"))
# Check new entity data created
self._check_entity_data_values(
"newentity", type_id="Default_type", type_uri="annal:Default_type",
update_dict=
{ '@type': ['annal:Default_type', 'annal:EntityData'] }
)
return
示例10: _check_entity_data_values
# 需要导入模块: from annalist.models.entitydata import EntityData [as 别名]
# 或者: from annalist.models.entitydata.EntityData import exists [as 别名]
def _check_entity_data_values(self,
entity_id, type_id="testtype", type_uri=None,
update="Entity", parent=None,
update_dict=None):
"Helper function checks content of form-updated record type entry with supplied entity_id"
recorddata = RecordTypeData.load(self.testcoll, type_id)
self.assertTrue(EntityData.exists(recorddata, entity_id))
e = EntityData.load(recorddata, entity_id)
self.assertEqual(e.get_id(), entity_id)
self.assertEqual(e.get_url(""), TestHostUri + entity_url("testcoll", type_id, entity_id))
v = entitydata_values(entity_id, type_id=type_id, type_uri=type_uri, update=update)
if update_dict:
v.update(update_dict)
for k in update_dict:
if update_dict[k] is None:
v.pop(k, None)
self.assertDictionaryMatch(e.get_values(), v)
return e
示例11: test_post_new_entity_new_type
# 需要导入模块: from annalist.models.entitydata import EntityData [as 别名]
# 或者: from annalist.models.entitydata.EntityData import exists [as 别名]
def test_post_new_entity_new_type(self):
self.assertFalse(EntityData.exists(self.testdata, "entitynewtype"))
f = entitydata_default_view_form_data(
entity_id="entitynewtype", action="new", update="Updated entity",
new_type="New type"
)
u = entitydata_edit_url("new", "testcoll", "testtype", view_id="Default_view")
r = self.client.post(u, f)
self.assertEqual(r.status_code, 302)
self.assertEqual(r.reason_phrase, "FOUND")
self.assertEqual(r.content, "")
v = TestHostUri + entitydata_edit_url("new", "testcoll", "_type", view_id="Type_view")
w = entitydata_edit_url("edit", "testcoll", "testtype", entity_id="entitynewtype", view_id="Default_view")
c = continuation_url_param(w)
self.assertIn(v, r['location'])
self.assertIn(c, r['location'])
self._check_entity_data_values("entitynewtype", update="Updated entity")
return
示例12: test_post_default_form_use_view
# 需要导入模块: from annalist.models.entitydata import EntityData [as 别名]
# 或者: from annalist.models.entitydata.EntityData import exists [as 别名]
def test_post_default_form_use_view(self):
self._create_entity_data("entityuseview")
self.assertTrue(EntityData.exists(self.testdata, "entityuseview"))
f = default_view_form_data(
entity_id="entityuseview", action="view",
use_view="_view/Type_view",
)
f.pop('entity_id', None)
u = entitydata_edit_url(
"view", "testcoll", "testtype", "entityuseview", view_id="Default_view"
)
r = self.client.post(u, f)
self.assertEqual(r.status_code, 302)
self.assertEqual(r.reason_phrase, "Found")
self.assertEqual(r.content, b"")
v = entitydata_edit_url(
"view", "testcoll", "testtype", entity_id="entityuseview", view_id="Type_view"
)
c = continuation_url_param("/testsite/c/testcoll/d/testtype/")
self.assertIn(v, r['location'])
self.assertIn(c, r['location'])
self._check_entity_data_values("entityuseview")
return