root/rdfalchemy/trunk/test/count_test.py

Revision 98, 1.0 KB (checked in by phil, 4 years 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.samples.doap import *
3from rdfalchemy.samples.foaf import *
4from rdflib import ConjunctiveGraph
5
6import logging
7log = logging.getLogger('rdfalchemy')
8if not log.handlers:
9    log.addHandler(logging.StreamHandler())
10#log.setLevel(10)
11
12
13Person.db=ConjunctiveGraph()
14
15def test_start():
16    assert len(Person.db) == 0
17    p=Person(last="Cooper")
18    assert len(Person.db) == 2
19
20
21
22Person.m=rdfMultiple(FOAF.multi)
23Person.l=rdfList(FOAF.list)
24Person.c=rdfContainer(FOAF.seq)
25
26def test_multi():
27    p=Person.ClassInstances().next()
28    p.m = [1,2.2,0,'a','','c']
29    assert len(Person.db) == 8
30   
31    p.m = ['a','b','c']
32    assert len(Person.db) == 5
33
34def test_list():
35    # set and reset a list
36    p=Person.ClassInstances().next()
37    p.l = [10,2.3,0,'A','','C']
38    assert len(Person.db) == 18
39   
40    p.l = [10,2.3,0]
41    assert len(Person.db) == 12
42
43def test_seq():
44    p=Person.ClassInstances().next()
45    p.c = range(10)
46    assert len(Person.db) == 24
47   
48    p.c = ['things', 44]
49    assert len(Person.db) == 16
50
51
Note: See TracBrowser for help on using the browser.