def test_not_exists(self): """Validation: when a folder must exist but does not.""" from natcap.invest import validation dirpath = os.path.join(self.workspace_dir, 'nonexistent_dir') validation_warning = validation.check_directory(dirpath, exists=True) self.assertTrue('not found' in validation_warning)
def test_valid_permissions(self): """Validation: folder permissions.""" from natcap.invest import validation self.assertEqual( None, validation.check_directory(self.workspace_dir, exists=True, permissions='rwx'))
def test_file(self): """Validation: when a file is given to folder validation.""" from natcap.invest import validation filepath = os.path.join(self.workspace_dir, 'some_file.txt') with open(filepath, 'w') as opened_file: opened_file.write('the text itself does not matter.') validation_warning = validation.check_directory(filepath, exists=True)
def test_workspace_not_exists(self): """Validation: when a folder's parent must exist with permissions.""" from natcap.invest import validation dirpath = 'foo' new_dir = os.path.join(self.workspace_dir, dirpath) self.assertEqual(None, validation.check_directory( new_dir, exists=False, permissions='rwx'))
def test_exists(self): """Validation: when a folder must exist and does.""" from natcap.invest import validation self.assertEqual( None, validation.check_directory(self.workspace_dir, exists=True))