def testArticleComparison(self): a1 = Article() a2 = Article() a1.sPg = 1 a2.sPg = 3 self.assertTrue(a1 < a2) self.assertTrue(a2 > a1) a3 =Article() a3.sPg = 5 a4 = Article() a4.sPg = 7 a5 = Article() a5.sPg = 9 self.assertEqual([a1, a2, a3, a4, a5], sorted([a5, a3, a4, a2, a1]))
def testTraversal(self): a = Article() i = Issue() p = Periodical() pr = Person() eg = EditorGroup() eg.periodical = p pr.name = "John Malcovitshy" p.title = "Periodicaltitle" eg.members = [pr] a.issue = i i.periodical = p a.makers = [pr] self.assertEqual(a.issue.periodical.title, "Periodicaltitle") self.assertEqual(a.makers[0].name, "John Malcovitshy") self.assertEqual(eg.members[0].name, "John Malcovitshy") self.assertEqual(eg.periodical.title, "Periodicaltitle") self.assertEqual(12, len(self.graph))
def testArticleMapping(self): self.assertEqual(0, len(self.graph)) a = Article() self.assertTrue(isinstance(list(self.graph.subjects())[0], BNode)) self.assertEqual(1, len(self.graph)) # bnode--rdf:type-->bibo:article a.title = "Testtitle" # + bnode--dc:title--> "Testtitle" self.assertEqual(2, len(self.graph)) self.assertEqual(1, len(list(self.graph.triples((None,DC['title'], None))))) self.assertEqual(a.title, "Testtitle") a.creators = ["Testcreator1", "Testcreator2"] #a.creators = "Testcreator" XXX hoe doe je assertRaises met assignment? a.abstract = "Testabstract" a.sPg = 1 a.ePg = 3 #TODO check string & int types in rdf a.auStr = "Author 1, author 2" a.section = "Testsection" a.ivrs = ["Testintervieuwer"] a.ives = [u"Testgeïntervieuwde"] self.assertEqual(11, len(self.graph))
nlr = Periodical("<http://rdf.freebase.com/rdf/en.new_left_review>") nlr.title = "New Left Review" nlr.issn = "0028-6060" nlr.shortTitle = "nlr" nlr.homepage = URIRef("http://www.newleftreview.org/") nlr56 = Issue("<tag:new-left-review-issue-56,2009-04-23>") nlr56.periodical = nlr nlr56.number = 56 nlr56.volume = 2 nlr56.title = "New Left Review 56 March-April 2009" nlr56.pubdate = "2009-03-09" nlr56.coverImg = URIRef("http://www.newleftreview.org/assets/images/NLR56cover.gif") a1 = Article("<tag:obama-at-manassas,2009-04-23>") a1.title = "Obama at Manassas" a1.creators = ["Mike Davis"] a1.abstract = "Does Obama’s victory signal a political turning point comparable to 1980 or 1932? Mike Davis maps county-level changes, from below—minority-majority demographics, subprime suburbs, white-collar financial worries—catalysed by the 2008 campaign. From above, realignment of American capital behind the Silicon President." a1.issue = nlr56 a2 = Article("<tag:freedoms-triumph,2009-04-23>") a2.creators = ["Dylan Riley"] a2.title = "Freedom's Triumph?" a2.abstract = "Reviving its classical definition, ‘rule of the propertyless’, Luciano Canfora recasts the story of democracy in Europe as one of successive defeats, with lessons from Louis Napoleon on the use of suffrage as legitimation for oligarchic rule. Dylan Riley assesses a remarkable historical polemic from the Italian philologist." a2.issue = nlr56 a3 = Article("<tag:giovanni-arrighi,2009-04-22>") a3.title = "Giovanni Arrighi: The Winding Paths of Capital" a3.ivrs = ["David Harvey"] a3.ives = ["Giovani Arrighi"]