|
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 | |
|---|
| 1 | from rdfalchemy import * |
|---|
| 2 | from rdfalchemy.samples.doap import * |
|---|
| 3 | from rdfalchemy.samples.foaf import * |
|---|
| 4 | from rdflib import ConjunctiveGraph |
|---|
| 5 | |
|---|
| 6 | import logging |
|---|
| 7 | log = logging.getLogger('rdfalchemy') |
|---|
| 8 | if not log.handlers: |
|---|
| 9 | log.addHandler(logging.StreamHandler()) |
|---|
| 10 | #log.setLevel(10) |
|---|
| 11 | |
|---|
| 12 | |
|---|
| 13 | Person.db=ConjunctiveGraph() |
|---|
| 14 | |
|---|
| 15 | def test_start(): |
|---|
| 16 | assert len(Person.db) == 0 |
|---|
| 17 | p=Person(last="Cooper") |
|---|
| 18 | assert len(Person.db) == 2 |
|---|
| 19 | |
|---|
| 20 | |
|---|
| 21 | |
|---|
| 22 | Person.m=rdfMultiple(FOAF.multi) |
|---|
| 23 | Person.l=rdfList(FOAF.list) |
|---|
| 24 | Person.c=rdfContainer(FOAF.seq) |
|---|
| 25 | |
|---|
| 26 | def 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 | |
|---|
| 34 | def 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 | |
|---|
| 43 | def 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 | |
|---|