Esempio n. 1
0
 def testSchemasCompose3Times(self):
   x = gcl.loads("""
     y = { x : int } { y : string } { z : bool };
   """)
   self.assertEquals(schema.ScalarSchema('string'), x['y'].tuple_schema.get_subschema('y'))
   self.assertEquals(schema.ScalarSchema('int'), x['y'].tuple_schema.get_subschema('x'))
   self.assertEquals(schema.ScalarSchema('bool'), x['y'].tuple_schema.get_subschema('z'))
Esempio n. 2
0
 def testSchemasCompose(self):
   x = gcl.loads("""
     Xint = { x : int; };
     y = Xint { x = 'bla'; y : string };
   """)
   self.assertEquals(schema.ScalarSchema('string'), x['y'].tuple_schema.get_subschema('y'))
   self.assertEquals(schema.ScalarSchema('int'), x['y'].tuple_schema.get_subschema('x'))
Esempio n. 3
0
 def testSchemaRefersToVariable(self):
     x = gcl.loads("""
   Xint = { x : int; };
   y : Xint = { x = 'bla' };
 """)
     self.assertEquals(schema.ScalarSchema('int'),
                       x['y'].tuple_schema.get_subschema('x'))
Esempio n. 4
0
    def testSubSchema(self):
        x = gcl.loads("""
      a : int;
    """)

        self.assertEquals(schema.ScalarSchema('int'),
                          x.tuple_schema.get_subschema('a'))
Esempio n. 5
0
 def setUp(self):
   self.int1 = schema.ScalarSchema('int')
   self.int2 = schema.ScalarSchema('int')
   self.string = schema.ScalarSchema('string')
Esempio n. 6
0
 def testListWithSpecFails(self):
   string_schema = schema.ScalarSchema('string')
   with self.assertRaises(exceptions.SchemaError):
     schema.from_spec([string_schema]).validate([1, 2])
Esempio n. 7
0
 def testListWithSpec(self):
   int_schema = schema.ScalarSchema('int')
   schema.from_spec([int_schema]).validate([3])
   schema.from_spec([int_schema]).validate([])
   schema.from_spec([int_schema]).validate([1, 2])
   schema.from_spec([]).validate([1, 2])
Esempio n. 8
0
 def testInheritSchemaWithOverriddenValueWhichIsAList(self):
   x = gcl.loads("""
     y = { x : [int] } { x = [3] };
   """)
   self.assertEquals(schema.ListSchema(schema.ScalarSchema('int')), x['y'].tuple_schema.get_subschema('x'))
Esempio n. 9
0
 def testListSchema(self):
   x = gcl.loads("""
     y = { x : [int] }
   """)
   self.assertEquals(schema.ListSchema(schema.ScalarSchema('int')), x['y'].tuple_schema.get_subschema('x'))
Esempio n. 10
0
 def testInheritSchemaWithOverriddenValue(self):
   x = gcl.loads("""
     y = { x : int } { x = 3 };
   """)
   self.assertEquals(schema.ScalarSchema('int'), x['y'].tuple_schema.get_subschema('x'))
Esempio n. 11
0
 def testCollapseEqualSchemas(self):
   self.collapsesTo(schema.ScalarSchema('int'), schema.ScalarSchema('int'),
                    schema.ScalarSchema('int'))
Esempio n. 12
0
 def testCollapseAniesRight(self):
   self.collapsesTo(schema.ScalarSchema('int'), schema.AnySchema(),
                    schema.ScalarSchema('int'))