#!/usr/bin/env python # encoding: utf-8 """ testBattery.py Created by on 2006-11-14. """ from interface import interface from queryableModel import queryableModel class pet(interface): __public_attributes__ = ('name', 'age', 'species') def __init__(self, name, age, species): self.name = name self.age = age self.species = species def __repr__(self): return '%s named %s is %i years old' % (`self.species`, `self.name`, self.age) def testQueries(): testObj = queryableModel() testObj.childAdd(pet('Daeken', 18, 'Human')) testObj.childAdd(pet('Nikashera', 18, 'Neko')) testObj.childAdd(pet('Joe Bob', 72, 'Human')) testObj.childAdd(pet('Dean', 76, 'Human')) print 'Humans:', testObj.query(lambda child: child.species == 'Human') print '18 year olds:', testObj.query(lambda child: child.age == 18) print 'Seniors:', testObj.query(lambda child: child.age > 65) testQueries()