def test_index_ensure_path_for_existing_dirs(patched_os): "Test utility method Index.ensure_path() for existing directories" # We'll need that inside of ensure_path() patched_os.path.dirname = os.path.dirname # Given that I have an index index = Index('') # When I call ensure_path(resource) against a directory that exists to # exists, it *SHOULD NOT* try to create the directory patched_os.path.isdir.return_value = True index.ensure_path('path/to/my/resource') patched_os.makedirs.called.should.be.false
def test_index_ensure_path(patched_os): "Test utility method Index.ensure_path()" # We'll need that inside of ensure_path() patched_os.path.dirname = os.path.dirname # Given that I have an index index = Index('') # When I call ensure_path(resource) against a directory that doesn't seem # to exist, it should try to create the directory for the resource patched_os.path.isdir.return_value = False index.ensure_path('path/to/my/resource') patched_os.makedirs.assert_called_once_with('path/to/my')