Esempio n. 1
0
    def test_schema_entity(self):
        s = Schema(**SCHEMA_1)
        self.assertRaises(ValidationError, s.entity, {'type': 'nosuch'})
        self.assertRaises(ValidationError, s.entity, {
            'type': 'listener',
            'nosuch': 'x'
        })
        e = s.entity({'host': 'foo', 'type': 'listener', 'name': 'listener-1'})
        self.assertEqual(e.attributes, {
            'host': 'foo',
            'name': 'listener-1',
            'type': 'org.example.listener'
        })
        self.assertEqual(e['host'], 'foo')
        self.assertRaises(ValidationError, e.__setitem__, 'nosuch', 'x')

        # The container entity itself has been deprecated
        self.assertTrue(s.entity_types['org.example.container'].deprecated)

        # This will make sure that deprecated flag defaults to false for entities
        self.assertFalse(s.entity_types['org.example.connector'].deprecated)

        # This will make sure that deprecated flag defaults to false for attributes of entities
        self.assertFalse(s.entity_types['org.example.listener'].
                         attributes['host'].deprecated)

        try:
            e.nosuch = 'x'
            self.fail("Expected exception")
        except:
            pass
Esempio n. 2
0
    def test_schema_entity(self):
        s = Schema(**SCHEMA_1)
        self.assertRaises(ValidationError, s.entity, {'type': 'nosuch'})
        self.assertRaises(ValidationError, s.entity, {'type': 'listener', 'nosuch': 'x'})
        e = s.entity({'type': 'listener', 'name':'x', 'host':'foo'})
        self.assertEqual(e.attributes, {'type': 'org.example.listener', 'name':'x', 'host':'foo'})
        self.assertEqual(e['host'], 'foo')
        self.assertRaises(ValidationError, e.__setitem__, 'nosuch', 'x')

        # The container entity itself has been deprecated
        self.assertTrue(s.entity_types['org.example.container'].deprecated)

        # The routerId attribute of the container entity has been deprecated
        self.assertTrue(s.entity_types['org.example.container'].attributes['routerId'].deprecated)

        # This will make sure that deprecated flag defaults to false for entities
        self.assertFalse(s.entity_types['org.example.connector'].deprecated)
        
        # This will make sure that deprecated flag defaults to false for attributes of entities
        self.assertFalse(s.entity_types['org.example.listener'].attributes['host'].deprecated)

        try:
            e.nosuch = 'x'
            self.fail("Expected exception")
        except: pass
Esempio n. 3
0
    def test_schema_entity(self):
        s = Schema(**SCHEMA_1)
        self.assertRaises(ValidationError, s.entity, {"type": "nosuch"})
        self.assertRaises(ValidationError, s.entity, {"type": "listener", "nosuch": "x"})
        e = s.entity({"host": "foo", "type": "listener", "name": "listener-1"})
        self.assertEqual(e.attributes, {"host": "foo", "name": "listener-1", "type": "org.example.listener"})
        self.assertEqual(e["host"], "foo")
        self.assertRaises(ValidationError, e.__setitem__, "nosuch", "x")

        # The container entity itself has been deprecated
        self.assertTrue(s.entity_types["org.example.container"].deprecated)

        # The routerId attribute of the container entity has been deprecated
        self.assertTrue(s.entity_types["org.example.container"].attributes["routerId"].deprecated)

        # This will make sure that deprecated flag defaults to false for entities
        self.assertFalse(s.entity_types["org.example.connector"].deprecated)

        # This will make sure that deprecated flag defaults to false for attributes of entities
        self.assertFalse(s.entity_types["org.example.listener"].attributes["host"].deprecated)

        try:
            e.nosuch = "x"
            self.fail("Expected exception")
        except:
            pass
Esempio n. 4
0
 def test_schema_entity(self):
     s = Schema(**SCHEMA_1)
     self.assertRaises(ValidationError, s.entity, {'type': 'nosuch'})
     self.assertRaises(ValidationError, s.entity, {'type': 'listener', 'nosuch': 'x'})
     e = s.entity({'type': 'listener', 'name':'x', 'addr':'foo'})
     self.assertEqual(e.attributes, {'type': 'org.example.listener', 'name':'x', 'addr':'foo'})
     self.assertEqual(e['addr'], 'foo')
     self.assertRaises(ValidationError, e.__setitem__, 'nosuch', 'x')
     try:
         e.nosuch = 'x'
         self.fail("Expected exception")
     except: pass
Esempio n. 5
0
 def test_schema_entity(self):
     s = Schema(**SCHEMA_1)
     self.assertRaises(ValidationError, s.entity, {"type": "nosuch"})
     self.assertRaises(ValidationError, s.entity, {"type": "listener", "nosuch": "x"})
     e = s.entity({"type": "listener", "name": "x", "addr": "foo"})
     self.assertEqual(e.attributes, {"type": "org.example.listener", "name": "x", "addr": "foo"})
     self.assertEqual(e["addr"], "foo")
     self.assertRaises(ValidationError, e.__setitem__, "nosuch", "x")
     try:
         e.nosuch = "x"
         self.fail("Expected exception")
     except:
         pass
Esempio n. 6
0
 def test_schema_entity(self):
     s = Schema(**SCHEMA_1)
     self.assertRaises(ValidationError, s.entity, {'type': 'nosuch'})
     self.assertRaises(ValidationError, s.entity, {
         'type': 'listener',
         'nosuch': 'x'
     })
     e = s.entity({'type': 'listener', 'name': 'x', 'addr': 'foo'})
     self.assertEqual(e.attributes, {
         'type': 'org.example.listener',
         'name': 'x',
         'addr': 'foo'
     })
     self.assertEqual(e['addr'], 'foo')
     self.assertRaises(ValidationError, e.__setitem__, 'nosuch', 'x')
     try:
         e.nosuch = 'x'
         self.fail("Expected exception")
     except:
         pass