summaryrefslogtreecommitdiff
path: root/tests/block_props_test.py
diff options
context:
space:
mode:
authorJosh Blum2013-07-09 23:38:50 -0700
committerJosh Blum2013-07-09 23:38:50 -0700
commitc1f3f2df1d859937f26770d24fe464b150251251 (patch)
tree7179c280a73d46b413458c0cc0b70841fa9c9a0b /tests/block_props_test.py
parent8c3ccbe2445a86678d87d03f6626881a2fddc7d5 (diff)
downloadsandhi-c1f3f2df1d859937f26770d24fe464b150251251.tar.gz
sandhi-c1f3f2df1d859937f26770d24fe464b150251251.tar.bz2
sandhi-c1f3f2df1d859937f26770d24fe464b150251251.zip
gras: rename props files to calls (for callable work)
Diffstat (limited to 'tests/block_props_test.py')
-rw-r--r--tests/block_props_test.py87
1 files changed, 0 insertions, 87 deletions
diff --git a/tests/block_props_test.py b/tests/block_props_test.py
deleted file mode 100644
index 7f5dad2..0000000
--- a/tests/block_props_test.py
+++ /dev/null
@@ -1,87 +0,0 @@
-# Copyright (C) by Josh Blum. See LICENSE.txt for licensing information.
-
-import unittest
-import gras
-import numpy
-
-class MyBlock(gras.Block):
- def __init__(self):
- gras.Block.__init__(self, "MyBlock")
- self.foo = 0
- self.register_call("get_foo", self.get_foo)
- self.register_call("set_foo", self.set_foo)
-
- def work(self, *args): pass
-
- def get_foo(self):
- return self.foo
-
- def set_foo(self, new_foo):
- print "new_foo", new_foo
- new_foo + 0 #throws if its not a number
- self.foo = new_foo
-
-class BlockPropsTest(unittest.TestCase):
-
- def test_property_set_get(self):
- my_block = MyBlock()
- self.assertEqual(my_block.foo, 0)
-
- my_block.set_foo(42)
- self.assertEqual(my_block.foo, 42)
-
- my_foo = my_block.get_foo()
- self.assertEqual(my_foo, 42)
-
- def test_property_errors(self):
- my_block = MyBlock()
-
- #property does not exist
- threw = False
- try: my_block.get_bar()
- except: threw = True
- self.assertTrue(threw)
-
- #wrong type for property
- threw = False
- try: my_block.set_foo(None)
- except: threw = True
- self.assertTrue(threw)
-
- def test_element_tree_paths(self):
- my_block = MyBlock()
- tb = gras.TopBlock()
- hb = gras.HierBlock()
-
- tb.adopt_element("my_hier", hb)
- hb.adopt_element("my_block", my_block)
-
- my_block.set_foo(42)
- self.assertEqual(my_block.get_foo(), 42)
-
- my_block0 = tb.locate_element('/my_hier/my_block')
- self.assertEqual(my_block0.get_foo(), 42)
-
- my_block1 = hb.locate_element('my_block')
- self.assertEqual(my_block1.get_foo(), 42)
-
- my_block2 = hb.locate_element('./../my_hier/my_block')
- self.assertEqual(my_block2.get_foo(), 42)
-
- threw = False
- try: hb.locate_element('../../my_hier/my_block')
- except: threw = True
- self.assertTrue(threw)
-
- threw = False
- try: hb.locate_element('../../my_hier/my_block0')
- except: threw = True
- self.assertTrue(threw)
-
- threw = False
- try: hb.locate_element('../../my_hier/my_block/test')
- except: threw = True
- self.assertTrue(threw)
-
-if __name__ == '__main__':
- unittest.main()