def test_validTemplate_hello(self): """ The config provided by the hello:python template should validate successfully. """ config = json.loads('''{ "type": "container", "options": { "pythonpath": [".."] }, "components": [ { "type": "class", "classname": "hello.hello.AppSession", "realm": "realm1", "transport": { "type": "websocket", "endpoint": { "type": "tcp", "host": "127.0.0.1", "port": 8080 }, "url": "ws://127.0.0.1:8080/ws" } } ] }''') checkconfig.check_container(config)
def test_extraKeys(self): """ A component with extra keys will fail. """ config = json.loads('''{ "type": "container", "options": { "pythonpath": [".."] }, "components": [ { "type": "class", "classname": "hello.hello.AppSession", "realm": "realm1", "woooooo": "bar", "transport": { "type": "websocket", "endpoint": { "type": "tcp", "host": "127.0.0.1", "port": 8080 }, "url": "ws://127.0.0.1:8080/ws" } } ] }''') with self.assertRaises(checkconfig.InvalidConfigException) as e: checkconfig.check_container(config) self.assertIn("encountered unknown attribute 'woooooo'", str(e.exception))
def test_requiredKeys(self): """ A component with missing keys fails. """ config = json.loads('''{ "type": "container", "options": { "pythonpath": [".."] }, "components": [ { "type": "class", "classname": "hello.hello.AppSession", "realm": "realm1" } ] }''') with self.assertRaises(checkconfig.InvalidConfigException) as e: checkconfig.check_container(config) self.assertIn("invalid component configuration - missing mandatory attribute 'transport'", str(e.exception))