示例#1
0
 def testValidateExtendedSchemaWhenCleartextTimestamp(self):
     """Test _ValidateExtendedSchema()."""
     schema = [{
         'name': u'foo1',
         'type': 'timestamp'
     }, {
         'name': 'foo2',
         'type': 'timestamp'
     }, {
         'name': 'foo3',
         'type': 'timestamp',
         'encrypt': load_lib.NONE
     }]
     load_lib._ValidateExtendedSchema(schema)
 def testReadandValidateMultipleNestedSchemaFromFile(self):
   infile = os.path.join(self.dirname, 'test_multiple_nested_schema_file')
   f = open(infile, 'wt')
   f.write(test_util.GetJobsSchemaString())
   f.close()
   read_schema = load_lib.ReadSchemaFile(infile)
   load_lib._ValidateExtendedSchema(read_schema)
   expected_schema = json.loads(test_util.GetJobsSchemaString())
   self.assertEquals(expected_schema, read_schema)
   # append some non-json text and check failure.
   f = open(infile, 'at')
   f.write('bogus')
   f.close()
   try:
     load_lib.ReadSchemaFile(infile)
     self.fail()
   except ValueError:
     pass  # success
示例#3
0
 def testReadandValidateMultipleNestedSchemaFromFile(self):
     infile = os.path.join(self.dirname, 'test_multiple_nested_schema_file')
     f = open(infile, 'wt')
     f.write(test_util.GetJobsSchemaString())
     f.close()
     read_schema = load_lib.ReadSchemaFile(infile)
     load_lib._ValidateExtendedSchema(read_schema)
     expected_schema = json.loads(test_util.GetJobsSchemaString())
     self.assertEquals(expected_schema, read_schema)
     # append some non-json text and check failure.
     f = open(infile, 'at')
     f.write('bogus')
     f.close()
     try:
         load_lib.ReadSchemaFile(infile)
         self.fail()
     except ValueError:
         pass  # success