root / rdfalchemy / trunk / test / get_test.py

Revision 98, 1.4 kB (checked in by phil, 10 months ago)

This reflects a change of all Descriptor names from a prefix of rdflib to rdf
This fixes improves the behavior of Literal for Decimal and datetime types
It also moves rdfSubject into a different file name
adds one unit test for literals

Line 
1from rdfalchemy import *
2from rdfalchemy.orm import mapper
3from rdfalchemy.samples.doap import *
4from rdfalchemy.samples.foaf import *
5from rdflib import ConjunctiveGraph
6
7import logging
8log = logging.getLogger()
9if not log.handlers:
10    log.addHandler(logging.StreamHandler())
11#log.setLevel(10)
12
13
14Person.db=ConjunctiveGraph()
15
16
17def test_addBNodeKnowsL():
18    Person.knows = rdfList(FOAF.knowsL, range_type=FOAF.Person)       
19    p1=Person(first="PhilipL")
20    p2=Person(last="Cooper" , first="Ben")
21    p3=Person(last="Cooper" , first="Matt")
22    p1.knows = [p2, p3]
23    p1=Person.get_by(first="PhilipL")
24    log.info("db len is %s"%len(Person.db))
25    assert len(p1.knows) == 2
26    del p1
27   
28def test_addBNodeKnowsC():
29    Person.knows = rdfContainer(FOAF.knowsC, range_type=FOAF.Person)       
30    mapper() 
31    p1=Person(first="PhilipC")
32    p2=Person(last="Cooper" , first="Ben")
33    p3=Person(last="Cooper" , first="Matt")
34    p1.knows = [p2, p3]
35    p1=Person.get_by(first="PhilipC")
36    log.info("db len is %s"%len(Person.db))
37    assert len(p1.knows) == 2
38    del p1
39   
40def test_addBNodeKnowsM():
41    Person.knows = rdfMultiple(FOAF.knowsM, range_type=FOAF.Person)       
42    mapper()
43    p1=Person(first="PhilipM")
44    p2=Person(last="Cooper" , first="Ben")
45    p3=Person(last="Cooper" , first="Matt")
46    p1.knows = [p2, p3]
47    p1=Person.get_by(first="PhilipM")
48    log.info("db len is %s"%len(Person.db))
49    assert len(p1.knows) == 2
50    del p1
51   
52   
Note: See TracBrowser for help on using the browser.