Пример #1
0
 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)
Пример #2
0
    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))
Пример #3
0
 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)
Пример #4
0
    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))
Пример #5
0
    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))
Пример #6
0
    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))