From 4d62e1152241854ab864142d827d735d84405078 Mon Sep 17 00:00:00 2001 From: rcoh Date: Sat, 12 Feb 2011 15:59:59 -0500 Subject: Modified the test code to automatically pick up new tests. Just add your test file to tests/__init__.py. Fixed a bug in ZigZagLayout. Added the BehaviorQuerySystem to allow querying on behaviors. Added the "ModulateColor" behavior which will continually shift a color along the HSV plane. Added TestBQS to test the behavior query system. Modified Behavior to have a getLastOutput and setLastOutput method. --- tests/TestBQS.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 tests/TestBQS.py (limited to 'tests/TestBQS.py') diff --git a/tests/TestBQS.py b/tests/TestBQS.py new file mode 100644 index 0000000..8dc90b2 --- /dev/null +++ b/tests/TestBQS.py @@ -0,0 +1,18 @@ +import unittest +import util.BehaviorQuerySystem as bqs +from behaviors.ColorChangerBehavior import * +class TestBQS(unittest.TestCase): + def setUp(self): + bqs.initBQS() + b = ColorChangerBehavior({'Id': 'color','ColorList':[(255,0,0)]}) + bqs.addBehavior(b) + b.addInput({'Location':(5,5)}) + b.timeStep() + def tearDown(self): + bqs.initBQS() + + def test_color_predicate(self): + validQuery = lambda args:args['Color']==(255,0,0) + invalidQuery = lambda args:args['Color']==(254,0,0) + assert bqs.query(validQuery) == [{'Color':(255,0,0), 'Location':(5,5)}] + assert bqs.query(invalidQuery) == [] -- cgit v1.2.3