|
Revision 136, 1.7 kB
(checked in by phil, 6 months ago)
|
|
RDFAlchemy added descriptors for locale and some tests
|
| Line | |
|---|
| 1 | #!/usr/bin/env python |
|---|
| 2 | # encoding: utf-8 |
|---|
| 3 | """ |
|---|
| 4 | subclass.py |
|---|
| 5 | |
|---|
| 6 | Created by Philip Cooper on 2008-05-14. |
|---|
| 7 | Copyright (c) 2008 Openvest. All rights reserved. |
|---|
| 8 | """ |
|---|
| 9 | |
|---|
| 10 | from rdfalchemy import rdfSubject, Namespace |
|---|
| 11 | from rdfalchemy.rdfsSubject import rdfsSubject |
|---|
| 12 | |
|---|
| 13 | NS = Namespace('http://example.com/project123/') |
|---|
| 14 | |
|---|
| 15 | class A(rdfSubject): |
|---|
| 16 | rdf_type = NS.A |
|---|
| 17 | |
|---|
| 18 | a1 = A() |
|---|
| 19 | a2 = A() |
|---|
| 20 | |
|---|
| 21 | class B(rdfSubject): |
|---|
| 22 | rdf_type = NS.B |
|---|
| 23 | |
|---|
| 24 | b1 = B() |
|---|
| 25 | b2 = B() |
|---|
| 26 | |
|---|
| 27 | class C(B): |
|---|
| 28 | rdf_type = NS.C |
|---|
| 29 | |
|---|
| 30 | c1 = C() |
|---|
| 31 | |
|---|
| 32 | class D(C): |
|---|
| 33 | rdf_type = NS.D |
|---|
| 34 | |
|---|
| 35 | d1 = D() |
|---|
| 36 | d2 = D() |
|---|
| 37 | d3 = D() |
|---|
| 38 | |
|---|
| 39 | |
|---|
| 40 | class E(A,C): |
|---|
| 41 | rdf_type = NS.D |
|---|
| 42 | |
|---|
| 43 | |
|---|
| 44 | def subclass_testLen1(): |
|---|
| 45 | "Test these things that are just rdfSubject ... no inferencing" |
|---|
| 46 | assert len(list(A.ClassInstances())) == 2 |
|---|
| 47 | assert len(list(B.ClassInstances())) == 2 |
|---|
| 48 | |
|---|
| 49 | def subclass_testLen2(): |
|---|
| 50 | "Test these things that are just rdfSubject ... no inferencing" |
|---|
| 51 | assert len(list(C.ClassInstances())) == 1 |
|---|
| 52 | assert len(list(D.ClassInstances())) == 3 |
|---|
| 53 | |
|---|
| 54 | class As(rdfsSubject): |
|---|
| 55 | rdf_type = NS.As |
|---|
| 56 | |
|---|
| 57 | a1 = As() |
|---|
| 58 | a2 = As() |
|---|
| 59 | |
|---|
| 60 | class Bs(rdfsSubject): |
|---|
| 61 | rdf_type = NS.Bs |
|---|
| 62 | |
|---|
| 63 | b1 = Bs() |
|---|
| 64 | b2 = Bs() |
|---|
| 65 | |
|---|
| 66 | class Cs(Bs): |
|---|
| 67 | rdf_type = NS.Cs |
|---|
| 68 | |
|---|
| 69 | c1 = Cs() |
|---|
| 70 | |
|---|
| 71 | class Ds(Cs): |
|---|
| 72 | rdf_type = NS.Ds |
|---|
| 73 | |
|---|
| 74 | d1 = Ds() |
|---|
| 75 | d2 = Ds() |
|---|
| 76 | d3 = Ds() |
|---|
| 77 | |
|---|
| 78 | def ssubclass_testLen1(): |
|---|
| 79 | "Test these things that are rdfSSubject ... with inferencing" |
|---|
| 80 | assert len(list(As.ClassInstances())) == 2, len(list(As.ClassInstances())) |
|---|
| 81 | assert len(list(Bs.ClassInstances())) == 6, len(list(Bs.ClassInstances())) |
|---|
| 82 | |
|---|
| 83 | def ssubclass_testLen2(): |
|---|
| 84 | "Test these things that are rdfsSubject ... with inferencing" |
|---|
| 85 | assert len(list(Cs.ClassInstances())) == 4, len(list(Cs.ClassInstances())) |
|---|
| 86 | assert len(list(Ds.ClassInstances())) == 3, len(list(Ds.ClassInstances())) |
|---|