tools/bdconfig/lib/google_hadoop/bdconfig_lib/path_validator_test.py
def _TestAbsoluteBase(
      self, validator_func, succeed_on_nonexistent_dir,
      succeed_on_file, succeed_on_dir):
    """Helper for failure cases of absolute path validators.

    Args:
      validator_func: The function to test for basic failure modes.
      succeed_on_nonexistent_dir: Whether validator_func accepts an
          absolute non-existent directory.
      succeed_on_file: Whether validator_func accepts an
          absolute existent file.
      succeed_on_dir: Whether validator_func accepts an
          absolute existent directory.
    """
    outcomes = {
        'file:///tmp': False,  # Must not be a URL
        '../': False,  # Must be absolute
        '': False,  # Cannot be empty
        self._nonexistent_dir: succeed_on_nonexistent_dir,
        self._test_filename: succeed_on_file,
        FLAGS.test_tmpdir: succeed_on_dir,
    }

    # Allowed to not be set
    self.assertTrue(validator_func(None))

    # Test all cases
    for path in outcomes:
      expect_success = outcomes[path]
      if expect_success:
        self.assertTrue(validator_func(path))
      else:
        self.assertRaises(flags_validators.Error, validator_func, path)
Helper for failure cases of absolute path validators.

    Args:
      validator_func: The function to test for basic failure modes.
      succeed_on_nonexistent_dir: Whether validator_func accepts an
          absolute non-existent directory.
      succeed_on_file: Whether validator_func accepts an
          absolute existent file.
      succeed_on_dir: Whether validator_func accepts an
          absolute existent directory.
    
Helper for failure cases of absolute path validators.
Helper for failure cases of absolute path validators .
def _TestAbsoluteBase(
      self, validator_func, succeed_on_nonexistent_dir,
      succeed_on_file, succeed_on_dir):
    outcomes = {
        'file:///tmp': False,  
        '../': False,  
        '': False,  
        self._nonexistent_dir: succeed_on_nonexistent_dir,
        self._test_filename: succeed_on_file,
        FLAGS.test_tmpdir: succeed_on_dir,
    }
    self.assertTrue(validator_func(None))
    for path in outcomes:
      expect_success = outcomes[path]
      if expect_success:
        self.assertTrue(validator_func(path))
      else:
        self.assertRaises(flags_validators.Error, validator_func, path)
def _TestAbsoluteBase ( self , validator_func , succeed_on_nonexistent_dir , succeed_on_file , succeed_on_dir ) : outcomes = { 'file:///tmp' : False , '../' : False , '' : False , self . _nonexistent_dir : succeed_on_nonexistent_dir , self . _test_filename : succeed_on_file , FLAGS . test_tmpdir : succeed_on_dir , } self . assertTrue ( validator_func ( None ) ) for path in outcomes : expect_success = outcomes [ path ] if expect_success : self . assertTrue ( validator_func ( path ) ) else : self . assertRaises ( flags_validators . Error , validator_func , path )
Helper for failure cases of absolute path validators.
Helper for failure cases of absolute path validators .
"""Helper for failure cases of absolute path validators.

    Args:
      validator_func: The function to test for basic failure modes.
      succeed_on_nonexistent_dir: Whether validator_func accepts an
          absolute non-existent directory.
      succeed_on_file: Whether validator_func accepts an
          absolute existent file.
      succeed_on_dir: Whether validator_func accepts an
          absolute existent directory.
    """ # Must not be a URL # Must be absolute # Cannot be empty # Allowed to not be set # Test all cases
self
validator_func
The function to test for basic failure modes.
The function to test for basic failure modes .
succeed_on_nonexistent_dir
Whether validator_func accepts an
absolute non-existent directory.
Whether validator_func accepts an absolute non - existent directory .
succeed_on_file
Whether validator_func accepts an
absolute existent file.
Whether validator_func accepts an absolute existent file .
succeed_on_dir
Whether validator_func accepts an
absolute existent directory.
Whether validator_func accepts an absolute existent directory .