root / rdfalchemy / trunk / test / subDocument_test.py

Revision 136, 1.1 kB (checked in by phil, 6 months ago)

RDFAlchemy added descriptors for locale and some tests

Line 
1from rdfalchemy import Namespace,rdfSingle,rdfMultiple
2from rdfalchemy.rdfsSubject import rdfsSubject
3
4
5DC = Namespace('http://purl.org/dc/terms/')
6BIBO = Namespace('http://purl.org/ontology/bibo/')
7FOAF = Namespace('http://xmlns.com/foaf/0.1/')
8SKOS = Namespace('http://www.w3.org/2004/02/skos/core#')
9
10class Document(rdfsSubject):
11    rdf_type = BIBO.Document
12    title = rdfSingle(DC['title'])
13    alt_titles = rdfMultiple(DC.alt)
14    date = rdfSingle(DC.date)
15    issued = rdfSingle(DC.issued)
16    modified = rdfSingle(DC.modified)
17    creators = rdfMultiple(DC.creator)
18    authorList = rdfMultiple(BIBO.authorList)
19    subjects = rdfMultiple(DC.subject, range_type=SKOS.Concept)
20
21class Book(Document):
22    rdf_type = BIBO.Book
23    publisher = rdfSingle(DC.publisher,range_type=FOAF.Organization)
24    series = rdfSingle(DC.isPartOf, range_type=BIBO.Series)
25
26
27x = Book(title="Some Title")
28y = Document(title="Another Title")
29
30def len_test():
31    assert len(list(Document.ClassInstances())) == 2, "wanted 2 ... one book and one document"
32
33for document in Document.ClassInstances():
34    print document.title
35
Note: See TracBrowser for help on using the browser.