Skip to content

Commit

Permalink
Skip directory permissions unit tests on Windows; update HISTORY
Browse files Browse the repository at this point in the history
  • Loading branch information
emilyanndavis committed Aug 28, 2024
1 parent 789ca5f commit 6ab5e43
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
1 change: 1 addition & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ Unreleased Changes
------------------
* Workbench
* Several small updates to the model input form UI to improve usability and visual consistency (https://github.com/natcap/invest/issues/912)
* Fixed a bug that was allowing readonly workspace directories on Windows (https://github.com/natcap/invest/issues/1599)

3.14.2 (2024-05-29)
-------------------
Expand Down
26 changes: 15 additions & 11 deletions tests/test_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import shutil
import stat
import string
import sys
import tempfile
import textwrap
import time
Expand Down Expand Up @@ -320,6 +321,20 @@ def test_valid_permissions(self):
self.assertEqual(None, validation.check_directory(
self.workspace_dir, permissions='rwx'))

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, must_exist=False, permissions='rwx'))

@unittest.skipIf(sys.platform.startswith('win'), 'requires support for os.chmod(), which is unreliable on Windows')
class DirectoryValidationMacOnly(unittest.TestCase):
"""Test Directory Permissions Validation."""

def test_invalid_permissions_r(self):
"""Validation: when a folder must have read/write/execute permissions but is missing write and execute permissions."""
from natcap.invest import validation
Expand Down Expand Up @@ -374,17 +389,6 @@ def test_invalid_permissions_wx(self):
validation_warning = validation.check_directory(tempdir, permissions='rwx')
self.assertEqual(validation_warning, validation.MESSAGES['NEED_PERMISSION_DIRECTORY'].format(permission='read'))

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, must_exist=False, permissions='rwx'))


class FileValidation(unittest.TestCase):
"""Test File Validator."""

Expand Down

0 comments on commit 6ab5e43

Please sign in to comment.