root / rdfalchemy / trunk / test / subclass_test.py

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"""
4subclass.py
5
6Created by Philip Cooper on 2008-05-14.
7Copyright (c) 2008 Openvest. All rights reserved.
8"""
9
10from rdfalchemy import rdfSubject, Namespace
11from rdfalchemy.rdfsSubject import rdfsSubject
12
13NS = Namespace('http://example.com/project123/')
14
15class A(rdfSubject):
16    rdf_type = NS.A
17
18a1 = A()
19a2 = A()
20
21class B(rdfSubject):
22    rdf_type = NS.B
23
24b1 = B()
25b2 = B()
26
27class C(B):
28    rdf_type = NS.C
29
30c1 = C()
31
32class D(C):
33    rdf_type = NS.D
34
35d1 = D()
36d2 = D()
37d3 = D()
38
39
40class E(A,C):
41    rdf_type = NS.D
42
43
44def 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   
49def 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   
54class As(rdfsSubject):
55    rdf_type = NS.As
56
57a1 = As()
58a2 = As()
59
60class Bs(rdfsSubject):
61    rdf_type = NS.Bs
62
63b1 = Bs()
64b2 = Bs()
65
66class Cs(Bs):
67    rdf_type = NS.Cs
68
69c1 = Cs()
70
71class Ds(Cs):
72    rdf_type = NS.Ds
73
74d1 = Ds()
75d2 = Ds()
76d3 = Ds()
77
78def 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   
83def 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()))   
Note: See TracBrowser for help on using the browser.