diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/TestComponentRegistry.py | 3 | ||||
-rw-r--r-- | tests/TestConfigLoaders.py | 3 | ||||
-rwxr-xr-x | tests/testosc.py | 36 |
3 files changed, 42 insertions, 0 deletions
diff --git a/tests/TestComponentRegistry.py b/tests/TestComponentRegistry.py index 5ada524..9de1a32 100644 --- a/tests/TestComponentRegistry.py +++ b/tests/TestComponentRegistry.py @@ -4,13 +4,16 @@ from operationscore.SmootCoreObject import SmootCoreObject class TestComponentRegistry(unittest.TestCase): def setUp(self): compReg.initRegistry() + def tearDown(self): compReg.clearRegistry() + def test_register_component_id_specified(self): comp = SmootCoreObject({'Id': 'obj1'}) compReg.registerComponent(comp) newcomp = compReg.getComponent('obj1') assert comp == newcomp + def test_register_new_id(self): comp = SmootCoreObject({}) cid =compReg.registerComponent(comp) diff --git a/tests/TestConfigLoaders.py b/tests/TestConfigLoaders.py index 17fc2d9..c79bbf1 100644 --- a/tests/TestConfigLoaders.py +++ b/tests/TestConfigLoaders.py @@ -7,8 +7,10 @@ import xml class TestConfigLoaders(unittest.TestCase): def setUp(self): pass + def tearDown(self): pass + def test_composite(self): parent = ElementTree() overrider = ElementTree() @@ -20,6 +22,7 @@ class TestConfigLoaders(unittest.TestCase): result = ElementTree(result) result.write('tests/testdata/compositeTESTout.xml') assert filecmp.cmp('tests/testdata/compositeTESTout.xml','tests/testdata/compositeTRUTH.xml') + def test_inheritance(self): result = Config.loadConfigFile('tests/testdata/inheritanceTEST.xml') diff --git a/tests/testosc.py b/tests/testosc.py new file mode 100755 index 0000000..6763f41 --- /dev/null +++ b/tests/testosc.py @@ -0,0 +1,36 @@ +#!/usr/bin/env python + +import liblo, sys + +# create server, listening on port 1234 +try: + server = liblo.Server(1234) +except liblo.ServerError, err: + print str(err) + sys.exit() + +def foo_bar_callback(path, args): + i, f = args + print "received message '%s' with arguments '%d' and '%f'" % (path, i, f) + +def foo_baz_callback(path, args, types, src, data): + print "received message '%s'" % path + print "blob contains %d bytes, user data was '%s'" % (len(args[0]), data) + +def fallback(path, args, types, src): + print "got unknown message '%s' from '%s'" % (path, src.get_url()) + for a, t in zip(args, types): + print "argument of type '%s': %s" % (t, a) + +# register method taking an int and a float +server.add_method("/foo/bar", 'if', foo_bar_callback) + +# register method taking a blob, and passing user data to the callback +server.add_method("/foo/baz", 'b', foo_baz_callback, "blah") + +# register a fallback for unhandled messages +server.add_method(None, None, fallback) + +# loop and dispatch messages every 100ms +while True: + server.recv(100) |