Added a foaf-multiple.ini, another.foaf4 and accompanying test in test_foaf.py

Removed unnecessary returns in foaf2config()
This commit is contained in:
Elias Torres 2006-09-07 03:23:13 -04:00
parent 7b13eece4d
commit a166531855
5 changed files with 76 additions and 5 deletions

View File

@ -1,17 +1,18 @@
from ConfigParser import ConfigParser
# input = foaf, output = ConfigParser
def foaf2config(rdf, config=None):
def foaf2config(rdf, config):
if not config or not config.sections():
config = ConfigParser()
return
# there should be only be 1 section
section = config.sections().pop()
try:
from RDF import Model, NS, Parser, Statement
except:
return config
return
if hasattr(rdf, 'read'):
rdf = rdf.read()
@ -84,7 +85,7 @@ def foaf2config(rdf, config=None):
config.add_section(feed)
config.set(feed, 'name', "%s (%s)" % (title, servicetitle))
return config
return
if __name__ == "__main__":
import sys, urllib

View File

@ -0,0 +1,38 @@
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:rss="http://purl.org/rss/1.0/"
xmlns:foaf="http://xmlns.com/foaf/0.1/">
<foaf:PersonalProfileDocument rdf:about="http://torrez.us/who">
<foaf:maker rdf:resource="http://torrez.us/who#elias"/>
<foaf:primaryTopic rdf:resource="http://torrez.us/who#elias"/>
</foaf:PersonalProfileDocument>
<foaf:Person rdf:about="http://torrez.us/who#anotherelias">
<foaf:name>Another Elias Torres</foaf:name>
<foaf:weblog>
<foaf:Document rdf:about="http://torrez.us/">
<dc:title>Elias Torres</dc:title>
<rdfs:seeAlso>
<rss:channel rdf:about="http://torrez.us/feed/rdf" />
</rdfs:seeAlso>
</foaf:Document>
</foaf:weblog>
<foaf:holdsAccount>
<foaf:OnlineAccount>
<foaf:accountServiceHomepage rdf:resource="http://del.icio.us/"/>
<foaf:accountName>SOMEID</foaf:accountName>
</foaf:OnlineAccount>
</foaf:holdsAccount>
<foaf:holdsAccount>
<foaf:OnlineAccount>
<foaf:accountServiceHomepage rdf:resource="http://flickr.com/"/>
<foaf:accountName>SOMEID</foaf:accountName>
</foaf:OnlineAccount>
</foaf:holdsAccount>
</foaf:Person>
</rdf:RDF>

View File

@ -0,0 +1,18 @@
[Planet]
name = FOAF Test Configuration
cache_directory = tests/work/config/cache
[tests/data/config/eliast.foaf]
content_type = foaf
random_setting = eliast
online_accounts =
http://del.icio.us/|http://del.icio.us/rss/{foaf:accountName}
http://flickr.com/|http://api.flickr.com/services/feeds/photos_public.gne?id={foaf:accountName}
[tests/data/config/another.foaf]
content_type = foaf
random_setting = another
online_accounts =
http://del.icio.us/|http://del.icio.us/rss/{foaf:accountName}
http://flickr.com/|http://api.flickr.com/services/feeds/photos_public.gne?id={foaf:accountName}

View File

@ -7,4 +7,3 @@ content_type = foaf
online_accounts =
http://del.icio.us/|http://del.icio.us/rss/{foaf:accountName}
http://flickr.com/|http://api.flickr.com/services/feeds/photos_public.gne?id={foaf:accountName}

View File

@ -91,6 +91,21 @@ class FoafTest(unittest.TestCase):
'http://del.icio.us/rss/eliast',
'http://torrez.us/feed/rdf'], feeds)
def test_multiple_subscriptions(self):
config.load('tests/data/config/foaf-multiple.ini')
self.assertEqual(2,len(config.reading_lists()))
feeds = config.subscriptions()
feeds.sort()
self.assertEqual(5,len(feeds))
self.assertEqual(['http://api.flickr.com/services/feeds/' +
'photos_public.gne?id=77366516@N00',
'http://api.flickr.com/services/feeds/' +
'photos_public.gne?id=SOMEID',
'http://del.icio.us/rss/SOMEID',
'http://del.icio.us/rss/eliast',
'http://torrez.us/feed/rdf'], feeds)
# these tests only make sense if libRDF is installed
try:
import RDF