def testValidateNamespace(self):
   self.assertIsNone(utils.validate_namespace('a'))
   self.assertIsNone(utils.validate_namespace('a-a'))
   self.assertIsNone(utils.validate_namespace('a123'))
   self.assertIsNone(utils.validate_namespace('123'))
   self.assertIsNone(utils.validate_namespace('1.2'))
   self.assertIsNone(utils.validate_namespace('a' * 99))
   self.assertIsNone(utils.validate_namespace(None))
   invalid_namespaces = [
       '',
       'a ',
       '/',
       '/a',
       'a/a',
       'a/',
       u'∆',
       'a\na',
       'a' * 250,
       ['a'],
   ]
   for namespace in invalid_namespaces:
     try:
       utils.validate_namespace(namespace)
     except ValueError:
       pass
     else:
       self.fail(
           'Invalid namespace should have failed: {!r}'.format(namespace))
Exemple #2
0
 def testValidateNamespace(self):
     self.assertIsNone(utils.validate_namespace('a'))
     self.assertIsNone(utils.validate_namespace('a-a'))
     self.assertIsNone(utils.validate_namespace('a123'))
     self.assertIsNone(utils.validate_namespace('123'))
     self.assertIsNone(utils.validate_namespace('1.2'))
     self.assertIsNone(utils.validate_namespace('a' * 99))
     self.assertIsNone(utils.validate_namespace(None))
     invalid_namespaces = [
         '',
         'a ',
         '/',
         '/a',
         'a/a',
         'a/',
         u'∆',
         'a\na',
         'a' * 250,
         ['a'],
     ]
     for namespace in invalid_namespaces:
         try:
             utils.validate_namespace(namespace)
         except ValueError:
             pass
         else:
             self.fail('Invalid namespace should have failed: {!r}'.format(
                 namespace))
Exemple #3
0
 def validate_path(path, namespace=None):
   utils.validate_dir_path(path)
   if namespace is not None:
     utils.validate_namespace(namespace)
Exemple #4
0
 def validate_path(path, namespace=None):
     utils.validate_dir_path(path)
     if namespace is not None:
         utils.validate_namespace(namespace)