Skip to content

Commit

Permalink
got tests working again, so that they expect URIRef objects instead o…
Browse files Browse the repository at this point in the history
…f URLs as strings
  • Loading branch information
edsu committed Aug 2, 2011
1 parent c424a81 commit 2b2eb63
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
18 changes: 9 additions & 9 deletions example.rdf
Expand Up @@ -5,25 +5,25 @@
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
>
<rdf:Description rdf:about="http://www.xyz.edu/~jane">
<ns1:email rdf:resource="mailto:jane-doe@xyz.edu"/>
<ns1:address rdf:nodeID="KgpYBTJD2"/>
<ns1:colleagues rdf:resource="http://www.xyz.edu/students/alicejones.html"/>
<ns1:colleagues rdf:resource="http://www.xyz.edu/students/bobsmith.html"/>
<ns1:image rdf:resource="janedoe.jpg"/>
<ns1:jobTitle>Professor</ns1:jobTitle>
<ns1:name>Jane Doe</ns1:name>
<ns1:email rdf:resource="mailto:jane-doe@xyz.edu"/>
<ns1:address rdf:nodeID="cAWDTLlT2"/>
<ns1:url rdf:resource="http://www.janedoe.com"/>
<ns1:telephone>(425) 123-4567</ns1:telephone>
<ns1:image rdf:resource="janedoe.jpg"/>
<rdf:type rdf:resource="http://schema.org/Person"/>
<ns1:colleagues rdf:resource="http://www.xyz.edu/students/alicejones.html"/>
<ns1:colleagues rdf:resource="http://www.xyz.edu/students/bobsmith.html"/>
<ns1:name>Jane Doe</ns1:name>
</rdf:Description>
<rdf:Description rdf:nodeID="KgpYBTJD2">
<ns2:addressLocality>Seattle</ns2:addressLocality>
<rdf:Description rdf:nodeID="cAWDTLlT2">
<ns2:addressRegion>WA</ns2:addressRegion>
<ns2:postalCode>98052</ns2:postalCode>
<ns2:streetAddress>
20341 Whitworth Institute
405 N. Whitworth
</ns2:streetAddress>
<ns2:addressRegion>WA</ns2:addressRegion>
<ns2:addressLocality>Seattle</ns2:addressLocality>
<rdf:type rdf:resource="http://schema.org/PostalAddress"/>
</rdf:Description>
</rdf:RDF>
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -2,7 +2,7 @@

setup(
name = 'rdflib-microdata',
version = '0.1',
version = '0.2.0',
description = "rdflib extension for parsing microdata into an rdf graph",
author = "Ed Summers",
author_email = "ehs@pobox.com",
Expand Down
5 changes: 3 additions & 2 deletions test.py
Expand Up @@ -9,20 +9,21 @@ class MicrodataParserTest(TestCase):
def test_parse(self):
g = Graph()
g.parse(open("example.html"), format="microdata")
g.serialize(open("example.rdf", "w"))

# seem to be the right amount of assertions?
self.assertEqual(len(g), 15)

# is there an person?
s = URIRef("http://www.xyz.edu/~jane")
person = Namespace("http://schema.org/Person#")
self.assertEqual(g.value(s, RDF.type), "http://schema.org/Person")
self.assertEqual(g.value(s, RDF.type), URIRef("http://schema.org/Person"))
self.assertEqual(g.value(s, person.telephone), "(425) 123-4567")

# is the person attached to an address?
addr = Namespace("http://schema.org/PostalAddress#")
a = BNode(g.value(s, person.address))
self.assertEqual(g.value(a, RDF.type), "http://schema.org/PostalAddress")
self.assertEqual(g.value(a, RDF.type), URIRef("http://schema.org/PostalAddress"))
self.assertEqual(g.value(a, addr.postalCode), "98052")

# TODO: test dates?

0 comments on commit 2b2eb63

Please sign in to comment.