From cb69d2e1c7ced951cbf7a31ee286b0ed92cab8a8 Mon Sep 17 00:00:00 2001 From: rcoh Date: Fri, 18 Feb 2011 16:56:43 -0500 Subject: Adding Epydoc generated docs. --- html/SmootLight.tests.TestBQS'-pysrc.html | 160 ++++++++++++++++++++++++++++++ 1 file changed, 160 insertions(+) create mode 100644 html/SmootLight.tests.TestBQS'-pysrc.html (limited to 'html/SmootLight.tests.TestBQS'-pysrc.html') diff --git a/html/SmootLight.tests.TestBQS'-pysrc.html b/html/SmootLight.tests.TestBQS'-pysrc.html new file mode 100644 index 0000000..48af701 --- /dev/null +++ b/html/SmootLight.tests.TestBQS'-pysrc.html @@ -0,0 +1,160 @@ + + + + + SmootLight.tests.TestBQS' + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + Package SmootLight :: + Package tests :: + Module TestBQS' + + + + + + +
[hide private]
[frames] | no frames]
+
+

Source Code for Module SmootLight.tests.TestBQS'

+
+ 1  import unittest 
+ 2  import util.BehaviorQuerySystem as bqs 
+ 3  from behaviors.ColorChangerBehavior import * 
+ 4  import util.Geo as geo 
+
5 -class TestBQS(unittest.TestCase): +
6 - def setUp(self): +
7 bqs.initBQS() + 8 b = ColorChangerBehavior({'Id': 'color','ColorList':[(255,0,0)]}) + 9 c = ColorChangerBehavior({'Id': 'color2', 'ColorList':[(0,0,255)]}) +10 bqs.addBehavior(b) +11 bqs.addBehavior(c) +12 b.addInput({'Location':(3,4)}) +13 c.addInput({'Location':(5,12)}) +14 b.timeStep() +15 c.timeStep() +
16 +
17 - def tearDown(self): +
18 bqs.initBQS() +
19 +
20 - def test_simple_query(self): +
21 validQuery = lambda args:args['Color']==(255,0,0) +22 invalidQuery = lambda args:args['Color']==(254,0,0) +23 assert bqs.query(validQuery) == [{'Color':(255,0,0), 'Location':(3,4)}] +24 assert bqs.query(invalidQuery) == [] +
25 +
26 - def test_dist_query(self): +
27 validDist = lambda args:geo.dist(args['Location'], (0,0)) <= 5 +28 invalidDist = lambda args:geo.dist(args['Location'], (0,0)) <= 2 +29 doubleDist = lambda args:geo.dist(args['Location'], (0,0)) <= 20 +30 +31 assert bqs.query(validDist) == [{'Color':(255,0,0), 'Location':(3,4)}] +32 assert bqs.query(invalidDist) == [] +33 assert bqs.query(doubleDist) == [{'Color':(255,0,0), 'Location':(3,4)}, {'Color':(0,0,255),\ +34 'Location':(5,12)}] +
35 - def test_complex_queries(self): +
36 validQuery = lambda args:args['Color']==(255,0,0) +37 doubleDist = lambda args:geo.dist(args['Location'], (0,0)) <= 20 +38 +39 twoPartPredicate = lambda args:doubleDist(args) and validQuery(args) +40 assert bqs.query(twoPartPredicate) == [{'Color':(255,0,0), 'Location':(3,4)}] +41 assert bqs.query([validQuery, doubleDist]) == [{'Color':(255,0,0), 'Location':(3,4)}] +
42 +
+
+ + + + + + + + + + + + + + + + + + + + + + + +
+ + + + -- cgit v1.2.3