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
def test_entitydata2_data(self): e = EntityData(self.testdata, "entitydata2") e.set_values(entitydata_create_values("entitydata2")) ed = e.get_values() self.assertEqual(set(ed.keys()), set(entitydata_value_keys())) v = entitydata_values("entitydata2") self.assertEqual(ed, {k:v[k] for k in entitydata_value_keys()}) return
def test_entitydata_create_load(self): e = EntityData.create(self.testdata, "entitydata1", entitydata_create_values("entitydata1")) self.assertEqual(e._entitydir, entitydata_dir(entity_id="entitydata1")) self.assertTrue(os.path.exists(e._entitydir)) ed = EntityData.load(self.testdata, "entitydata1").get_values() v = entitydata_values("entitydata1") self.assertKeysMatch(ed, v) self.assertDictionaryMatch(ed, v) return
def _check_entity_data_values(self, entity_id, type_id="testtype", update="Entity", comment2="Comment field 2", comment3="Comment field 3" ): "Helper function checks content of form-updated record type entry with supplied entity_id" # log.info("_check_entity_data_values: type_id %s, entity_id %s"%(type_id, entity_id)) typeinfo = EntityTypeInfo(self.testcoll, type_id) self.assertTrue(typeinfo.entityclass.exists(typeinfo.entityparent, entity_id)) e = typeinfo.entityclass.load(typeinfo.entityparent, entity_id) self.assertEqual(e.get_id(), entity_id) v = entitydata_values(entity_id, type_id=type_id, update=update) v = entitydata_values_add_field(v, "rdfs:comment", 2, comment2) v = entitydata_values_add_field(v, "rdfs:comment_alt", 3, comment3) self.assertDictionaryMatch(e.get_values(), v) return e
def _check_entity_data_values(self, entity_id, type_id="testtype", update="Entity", comment2="Comment field 2", comment3="Comment field 3" ): "Helper function checks content of form-updated record type entry with supplied entity_id" # log.info("_check_entity_data_values: type_id %s, entity_id %s"%(type_id, entity_id)) typeinfo = EntityTypeInfo(self.testcoll, type_id) self.assertTrue(typeinfo.entityclass.exists(typeinfo.entityparent, entity_id)) e = typeinfo.entityclass.load(typeinfo.entityparent, entity_id) self.assertEqual(e.get_id(), entity_id) v = entitydata_values(entity_id, type_id=type_id, update=update) v = entitydata_values_add_field(v, "rdfs:comment", 2, comment2) v = entitydata_values_add_field(v, "rdfs:comment_alt", 3, comment3) self.assertDictionaryMatch(e.get_values(), v) return e
def _check_entity_data_values(self, entity_id, type_id="testtype", update="Entity", update_dict=None): "Helper function checks content of form-updated record type entry with supplied entity_id" # log.info("_check_entity_data_values: type_id %s, entity_id %s"%(type_id, entity_id)) typeinfo = EntityTypeInfo(self.testsite, self.testcoll, type_id) self.assertTrue(typeinfo.entityclass.exists(typeinfo.entityparent, entity_id)) e = typeinfo.entityclass.load(typeinfo.entityparent, entity_id) self.assertEqual(e.get_id(), entity_id) self.assertEqual(e.get_view_url(""), TestHostUri + entity_url("testcoll", type_id, entity_id)) v = entitydata_values(entity_id, type_id=type_id, update=update) if update_dict: v.update(update_dict) for k in update_dict: if update_dict[k] is None: v.pop(k, None) # log.info(e.get_values()) self.assertDictionaryMatch(e.get_values(), v) return e
def _check_entity_data_values(self, entity_id, type_id="testtype", update="Entity", update_dict=None): "Helper function checks content of form-updated record type entry with supplied entity_id" # log.info("_check_entity_data_values: type_id %s, entity_id %s"%(type_id, entity_id)) typeinfo = EntityTypeInfo(self.testcoll, type_id) self.assertTrue(typeinfo.entityclass.exists(typeinfo.entityparent, entity_id)) e = typeinfo.entityclass.load(typeinfo.entityparent, entity_id) self.assertEqual(e.get_id(), entity_id) self.assertEqual(e.get_view_url(""), TestHostUri + entity_url("testcoll", type_id, entity_id)) v = entitydata_values(entity_id, type_id=type_id, update=update) if update_dict: v.update(update_dict) for k in update_dict: if update_dict[k] is None: v.pop(k, None) # log.info(e.get_values()) self.assertDictionaryMatch(e.get_values(), v) return e