示例#1
0
 def test_alumniSuperproperty(self):
   p_alumni = VTerm.getTerm("alumni")
   p_alumniOf = VTerm.getTerm("alumniOf")
   p_suggestedAnswer = VTerm.getTerm("suggestedAnswer")
   self.assertFalse(p_alumni in p_suggestedAnswer.getSupers(), "not suggestedAnswer subPropertyOf alumni.")
   self.assertFalse(p_suggestedAnswer in p_alumni.getSupers(), "not alumni subPropertyOf suggestedAnswer.")
   self.assertFalse(p_alumni in p_alumni.getSupers(), "not alumni subPropertyOf alumni.")
   self.assertFalse(p_alumniOf in p_alumni.getSupers(), "not alumni subPropertyOf alumniOf.")
   self.assertFalse(p_suggestedAnswer in p_suggestedAnswer.getSupers(), "not suggestedAnswer subPropertyOf suggestedAnswer.")
示例#2
0
  def test_alumniInverse(self):
    p_alumni = VTerm.getTerm("alumni")
    p_alumniOf = VTerm.getTerm("alumniOf")
    p_suggestedAnswer = VTerm.getTerm("suggestedAnswer")

    #log.info("alumni: " + str(p_alumniOf.getInverseOf() ))

    self.assertTrue(p_alumni == p_alumniOf.getInverseOf(), "alumniOf inverseOf alumni." )
    self.assertTrue(p_alumniOf == p_alumni.getInverseOf(), "alumni inverseOf alumniOf." )

    self.assertFalse(p_alumni == p_alumni.getInverseOf(), "Not alumni inverseOf alumni." )
    self.assertFalse(p_alumniOf == p_alumniOf.getInverseOf(), "Not alumniOf inverseOf alumniOf." )
    self.assertFalse(p_alumni == p_suggestedAnswer.getInverseOf(), "Not answer inverseOf alumni." )
示例#3
0
 def test_FooBarIsNotClass(self):
   tFooBar = VTerm.getTerm("FooBar")
   try:
     tFooBarIsClass = tFooBar.isClass()
     self.assertFalse(tFooBarIsClass, "FooBar is not a class (should be None)")
     log.info("FooBar:" + str(tFooBar) )
   except:
     log.debug("Failed to get FooBar, as expected. So can't ask it if it isClass().")
示例#4
0
 def test_enumCommentCount(self):
   enum_comment_errors=[]
   for ev in VTerm.getAllEnumerations():
     comments = ev.getGetComments()
     log.debug("enumeration '%s': Expected 1 rdfs:comment, found: %s.\n" % ( ev.getId(), str(len(comments)  )) )
     if len(comments) != 1:
      enum_comment_errors.append ("enumerated value %s: Expected 1 rdfs:comment, found: %s.\n %s" % (e.id, len(comments), andstr.join(comments) ) )
   log.debug("enum comment count: "+ str(len(enum_comment_errors)))
   self.assertTrue(len(enum_comment_errors)==0, "Comment count enumeration errors. Aggregated: \n\n" + " \n".join(enum_comment_errors))
示例#5
0
  def test_gotThing(self):

     thing = VTerm.getTerm("Thing")
     if thing is None:
       gotThing = False
     else:
       gotThing = True

     self.assertEqual( gotThing, True, "Thing node should be accessible via GetUnit('Thing').")
示例#6
0
 def test_propCommentCount(self):
   prop_comment_errors=[]
   for p in VTerm.getAllProperties():
     comments = p.getComments()
     log.debug("property %s props %s" % (p.getId(), str(len(comments)) ))
     if len(comments) != 1:
       prop_comment_errors.append ("property '%s': Expected 1 rdfs:comment, found: %s.\n %s" % (p.getId(), len(comments), andstr.join(comments) ) )
   log.debug("property comment count: %s\n" % str(len(prop_comment_errors)))
   self.assertEqual(len(prop_comment_errors), 0, "Comment count property errors. Aggregated: \n\n" + " \n\n".join(prop_comment_errors))
示例#7
0
 def test_typeCommentCount(self):
   type_comment_errors=[]
   for t in VTerm.getAllTypes():
     comments = t.getComments()
     log.debug(t.getId() + " " + str(len(comments)))
     if len(comments) != 1:
      type_comment_errors.append ("type '%s': Expected 1 rdfs:comment, found: %s.\n %s" % (t.getId(), len(comments), andstr.join(comments) ) )
   log.debug("type comment count: "+ str(len(type_comment_errors)))
   self.assertTrue(len(type_comment_errors)==0, "Comment count type errors. Aggregated: \n" + " \n\n".join(type_comment_errors))
示例#8
0
  def test_gotFooBarThing(self):

     foobar = VTerm.getTerm("FooBar")
     if foobar is None:
       gotFooBar = False
     else:
       gotFooBar = True

     self.assertEqual( gotFooBar, False, "Thing node should NOT be accessible via GetUnit('FooBar').")
示例#9
0
 def test_DataTypeSupertypeDataType(self):
     tDataType = VTerm.getTerm("DataType")
     self.assertTrue(tDataType.subClassOf(tDataType),
                     "DataType subClassOf DataType.")
示例#10
0
 def test_NewsArticleSupertypeArticle(self):
     tNewsArticle = VTerm.getTerm("NewsArticle")
     tArticle = VTerm.getTerm("Article")
     self.assertFalse(tArticle.subClassOf(tNewsArticle),
                      "Article is not a sub-type of NewsArticle")
示例#11
0
 def test_EnumerationIsEnumeration(self):
     eEnumeration = VTerm.getTerm("Enumeration")
     self.assertTrue(eEnumeration.isEnumeration(),
                     "Enumeration is an Enumeration type.")
示例#12
0
 def test_answerSubpropertiesArrayLen(self):
     p_suggestedAnswer = VTerm.getTerm("suggestedAnswer")
     log.info("suggestedAnswer array: " + str(p_suggestedAnswer.getSubs()))
     self.assertEqual(p_suggestedAnswer.getSubs(), 0,
                      "answer subproperties() gives array of len 1.")
示例#13
0
 def test_EventCancelledIsEnumerationValue(self):
     eEventCancelled = VTerm.getTerm("EventCancelled")
     self.assertTrue(eEventCancelled.isEnumerationValue(),
                     "EventCancelled is an Enumeration value.")
示例#14
0
 def test_answerSubpropertiesArrayLen(self):
   p_offers = VTerm.getTerm("offers")
   self.assertEqual(len(p_offers.getSubs()), 0, "offers subproperties() gives array of len 0.")
示例#15
0
 def test_GetImmediateSubtypesWrong(self):
     tArticle = VTerm.getTerm("CreativeWork")
     self.assertFalse(
         VTerm.getTerm("NewsArticle") in tArticle.getSubs(),
         "CreativeWork is not in immediate subtypes of Article.")
示例#16
0
 def test_answerSubproperties(self):
   p_suggestedAnswer = VTerm.getTerm("suggestedAnswer")
   p_acceptedAnswer = VTerm.getTerm("acceptedAnswer")
   self.assertTrue(p_acceptedAnswer == p_suggestedAnswer.getSubs()[0], "suggestedAnswer subproperties(), acceptedAnswer in 0th element of array.")
示例#17
0
 def test_answerSubpropertiesArrayLen(self):
   p_suggestedAnswer = VTerm.getTerm("suggestedAnswer")
   log.info("suggestedAnswer array: "+ str(p_suggestedAnswer.getSubs() ))
   self.assertEqual(p_suggestedAnswer.getSubs(), 0, "answer subproperties() gives array of len 1.")
示例#18
0
 def test_answerSubproperty(self):
   p_suggestedAnswer = VTerm.getTerm("suggestedAnswer")
   p_acceptedAnswer = VTerm.getTerm("acceptedAnswer")
   subs = p_suggestedAnswer.getSubs()
   self.assertTrue(p_acceptedAnswer in subs, "acceptedAnswer is a subPropertyOf suggestedAanswer.")
示例#19
0
 def test_acceptedAnswerSuperpropertiesArrayLen(self):
   p_acceptedAnswer = VTerm.getTerm("acceptedAnswer")
   aa_supers = p_acceptedAnswer.getSupers()
   for f in aa_supers:
       log.info("acceptedAnswer's subproperties(): %s" % f.id)
   self.assertTrue( len(aa_supers) == 1, "acceptedAnswer subproperties() gives array of len 1. Actual: %s ." % len(aa_supers) )
示例#20
0
 def test_offersNotSupersededByActor(self):
   p_actor = VTerm.getTerm("actor")
   p_offers = VTerm.getTerm("offers")
   self.assertFalse(p_offers in p_actor.getSupersedes(), "offers property doesn't supersede actors property.")
示例#21
0
 def test_actorNotSupersededByOffers(self):
   p_actor = VTerm.getTerm("actor")
   p_offers = VTerm.getTerm("offers")
   self.assertFalse(p_actor in p_offers.getSupersedes(), "actor property doesn't supersede offers property.")
示例#22
0
 def test_actorSupersedesActors(self):
   p_actor = VTerm.getTerm("actor")
   p_actors = VTerm.getTerm("actors")
   self.assertTrue(p_actors in p_actor.getSupersedes(), "actor supersedes actors.")
示例#23
0
 def test_PersonNotAttribute(self):
     tPerson = VTerm.getTerm("Person")
     self.assertFalse(tPerson.isProperty(),
                      "Not true that Person isAttribute().")
示例#24
0
 def test_GetImmediateSubtypesWrong(self):
   tArticle = VTerm.getTerm("CreativeWork")
   self.assertFalse(VTerm.getTerm("NewsArticle") in tArticle.getSubs(), "CreativeWork is not in immediate subtypes of Article.")
示例#25
0
 def test_actorNotSuperseded(self):
   p_actor = VTerm.getTerm("actor")
   self.assertFalse(p_actor.superseded(), "actor property has not been superseded.")
示例#26
0
 def test_EventStatusTypeIsEnumeration(self):
   eEventStatusType = VTerm.getTerm("EventStatusType")
   self.assertTrue(eEventStatusType.isEnumeration(), "EventStatusType is an Enumeration.")
示例#27
0
 def test_EventStatusTypeIsEnumeration(self):
     eEventStatusType = VTerm.getTerm("EventStatusType")
     self.assertTrue(eEventStatusType.isEnumeration(),
                     "EventStatusType is an Enumeration.")
示例#28
0
 def test_EventStatusTypeIsntEnumerationValue(self):
   eEventStatusType = VTerm.getTerm("EventStatusType")
   self.assertFalse(eEventStatusType.isEnumerationValue(), "EventStatusType is not an Enumeration value.")
示例#29
0
 def test_dualPath(self):
     self.assertEqual(
         len(
             GetParentPathTo(VTerm.getTerm("Restaurant"),
                             VTerm.getTerm("Thing"))), 2,
         "2 supertype paths from Restaurant to Thing.")
示例#30
0
 def test_EventCancelledIsEnumerationValue(self):
   eEventCancelled = VTerm.getTerm("EventCancelled")
   self.assertTrue(eEventCancelled.isEnumerationValue(), "EventCancelled is an Enumeration value.")
示例#31
0
 def test_ItemAvailabilityIsEnumeration(self):
     eItemAvailability = VTerm.getTerm("ItemAvailability")
     self.assertTrue(eItemAvailability.isEnumeration(),
                     "ItemAvailability is an Enumeration.")
示例#32
0
 def test_EventTotallyFooBarIsntEnumerationValue(self):
   eEventCancelledFB = VTerm.getTerm("EventTotallyFooBar")
   if eEventCancelledFB is not None:
     self.assertFalse(eEventCancelledFB.isEnumerationValue(), "EventTotallyFooBar is not an Enumeration value, not even a node.")
   self.assertTrue(eEventCancelledFB is None, "EventTotallyFooBar should not resolve to a node.")
示例#33
0
 def test_ArticleSupertypeNewsArticle(self):
     tNewsArticle = VTerm.getTerm("NewsArticle")
     tArticle = VTerm.getTerm("Article")
     self.assertTrue(tNewsArticle.subClassOf(tArticle),
                     "NewsArticle is a sub-type of Article")
示例#34
0
 def test_ThingNotSupertypePerson(self):
     tThing = VTerm.getTerm("Thing")
     tPerson = VTerm.getTerm("Person")
     self.assertFalse(tThing.subClassOf(tPerson),
                      "Thing not subClassOf Person.")
示例#35
0
 def test_ThingSupertypeThing(self):
     tThing = VTerm.getTerm("Thing")
     self.assertTrue(tThing.subClassOf(tThing), "Thing subClassOf Thing.")
示例#36
0
 def test_StoresArePlaces(self):
     tStore = VTerm.getTerm("Store")
     tPlace = VTerm.getTerm("Place")
     self.assertTrue(tStore.subClassOf(tPlace), "Store subClassOf Place.")
示例#37
0
 def test_PersonSupertypeThing(self):
     tThing = VTerm.getTerm("Thing")
     tPerson = VTerm.getTerm("Person")
     self.assertTrue(tPerson.subClassOf(tThing), "Person subClassOf Thing.")
示例#38
0
 def test_offersNotSuperseded(self):
   p_offers = VTerm.getTerm("offers")
   self.assertFalse(p_offers.superseded(), "offers property has not been superseded.")
示例#39
0
 def test_StoreSupertypeLocalBusiness(self):
     tStore = VTerm.getTerm("Store")
     tLocalBusiness = VTerm.getTerm("LocalBusiness")
     self.assertTrue(tStore.subClassOf(tLocalBusiness),
                     "Store subClassOf LocalBusiness.")
示例#40
0
 def test_actorsSuperseded(self):
     p_actors = VTerm.getTerm("actors")
     self.assertTrue(p_actors.superseded(),
                     "actors property has been superseded.")
示例#41
0
 def test_StoresAreOrganizations(self):
     tStore = VTerm.getTerm("Store")
     tOrganization = VTerm.getTerm("Organization")
     self.assertTrue(tStore.subClassOf(tOrganization),
                     "Store subClassOf Organization.")
示例#42
0
 def test_offersNotSuperseded(self):
     p_offers = VTerm.getTerm("offers")
     self.assertFalse(p_offers.superseded(),
                      "offers property has not been superseded.")
示例#43
0
 def test_GetImmediateSubtypesOk(self):
     tArticle = VTerm.getTerm("Article")
     self.assertTrue(
         VTerm.getTerm("NewsArticle") in tArticle.getSubs(),
         "NewsArticle is in immediate subtypes of Article.")
示例#44
0
 def test_offersNotSupersededByActor(self):
     p_actor = VTerm.getTerm("actor")
     p_offers = VTerm.getTerm("offers")
     self.assertFalse(p_offers in p_actor.getSupersedes(),
                      "offers property doesn't supersede actors property.")
示例#45
0
 def test_actorSupersedesActors(self):
     p_actor = VTerm.getTerm("actor")
     p_actors = VTerm.getTerm("actors")
     self.assertTrue(p_actors in p_actor.getSupersedes(),
                     "actor supersedes actors.")
示例#46
0
 def test_actorsSuperseded(self):
   p_actors = VTerm.getTerm("actors")
   self.assertTrue(p_actors.superseded(), "actors property has been superseded.")
示例#47
0
 def test_actorNotSuperseded(self):
     p_actor = VTerm.getTerm("actor")
     self.assertFalse(p_actor.superseded(),
                      "actor property has not been superseded.")
示例#48
0
 def test_booleanDataType(self):
   self.assertTrue(VTerm.getTerm("Boolean").isDataType())
   self.assertTrue(VTerm.getTerm("DataType").isDataType())
   self.assertFalse(VTerm.getTerm("Thing").isDataType())
   self.assertFalse(VTerm.getTerm("Duration").isDataType())
示例#49
0
 def test_actorNotSupersededByOffers(self):
     p_actor = VTerm.getTerm("actor")
     p_offers = VTerm.getTerm("offers")
     self.assertFalse(p_actor in p_offers.getSupersedes(),
                      "actor property doesn't supersede offers property.")
示例#50
0
 def test_html_tree(self):
     uThing = VTerm.getTerm("Thing")
     mainroot = TypeHierarchyTree("local_label")
     mainroot.traverseForHTML(uThing, layers="core", idprefix="C.")
     html = mainroot.toHTML()
     self.assertTrue( html != None and len(html) > 0, "traverseForHTML should return content")
示例#51
0
 def test_answerSubproperty(self):
     p_suggestedAnswer = VTerm.getTerm("suggestedAnswer")
     p_acceptedAnswer = VTerm.getTerm("acceptedAnswer")
     subs = p_suggestedAnswer.getSubs()
     self.assertTrue(p_acceptedAnswer in subs,
                     "acceptedAnswer is a subPropertyOf suggestedAanswer.")
示例#52
0
 def test_jsonld_tree(self):
     uThing = VTerm.getTerm("Thing")
     mainroot = TypeHierarchyTree()
     mainroot.traverseForJSONLD(uThing, layers="core")
     thing_tree = mainroot.toJSON()
     self.assertTrue( thing_tree != None and len(thing_tree) > 0, "traverseForJSONLD should return content")
示例#53
0
 def test_answerSubpropertiesArrayLen(self):
     p_offers = VTerm.getTerm("offers")
     self.assertEqual(len(p_offers.getSubs()), 0,
                      "offers subproperties() gives array of len 0.")
示例#54
0
    def test_simplePath(self):

      self.assertEqual(  len(
                  GetParentPathTo(VTerm.getTerm("CreativeWork"), VTerm.getTerm("Thing"))
                  ), 1, "1 supertype path from CreativeWork to Thing."  )
示例#55
0
 def test_EventStatusTypeIsntEnumerationValue(self):
     eEventStatusType = VTerm.getTerm("EventStatusType")
     self.assertFalse(eEventStatusType.isEnumerationValue(),
                      "EventStatusType is not an Enumeration value.")
示例#56
0
 def test_dualPath(self):
   self.assertEqual(  len(
               GetParentPathTo(VTerm.getTerm("Restaurant"), VTerm.getTerm("Thing"))
               ), 2, "2 supertype paths from Restaurant to Thing."  )
示例#57
0
 def test_booleanDataType(self):
     self.assertTrue(VTerm.getTerm("Boolean").isDataType())
     self.assertTrue(VTerm.getTerm("DataType").isDataType())
     self.assertFalse(VTerm.getTerm("Thing").isDataType())
     self.assertFalse(VTerm.getTerm("Duration").isDataType())
示例#58
0
 def test_inverseDualPath(self):
   self.assertEqual(  len(
               GetParentPathTo(VTerm.getTerm("Thing"), VTerm.getTerm("Restaurant"))
               ), 0, "0 supertype paths from Thing to Restaurant."  )
示例#59
0
 def test_inverseDualPath(self):
     self.assertEqual(
         len(
             GetParentPathTo(VTerm.getTerm("Thing"),
                             VTerm.getTerm("Restaurant"))), 0,
         "0 supertype paths from Thing to Restaurant.")
示例#60
0
 def test_QuantityisClass(self):
     tQuantity = VTerm.getTerm("Quantity")
     self.assertTrue(tQuantity.isClass(), "Quantity is a class.")