Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allowing non empty dirs to be deleted #3108

Merged
merged 13 commits into from Dec 5, 2017

Conversation

Projects
None yet
2 participants
@kirit93
Copy link
Contributor

kirit93 commented Dec 4, 2017

Fixes #2760

kirit93 added some commits Dec 4, 2017

@kirit93

This comment has been minimized.

Copy link
Contributor Author

kirit93 commented Dec 5, 2017

@takluyver It seems that the delete function is unable to delete the unicode directory from the test case. However the only changes I made to the delete function are those that allow directories to be deleted so I am unsure why unicode isn't being deleted.


if self.delete_to_trash:
if os.path.isdir(os_path):
listing = os.listdir(os_path)
# Don't send non-empty directories to trash.

This comment has been minimized.

@takluyver

takluyver Dec 5, 2017

Member

I think you've got this backwards. The idea is that if we're using trash (if self.delete_to_trash is true), then we can delete non-empty directories, because the user can get them back from trash. If we're not using trash, then deleting is permanent, so we should still refuse to delete non-empty directories.

@@ -518,7 +518,8 @@ def test_delete_dirs(self):
for name in sorted(self.dirs + ['/'], key=len, reverse=True):
listing = self.api.list(name).json()['content']
for model in listing:
self.api.delete(model['path'])
if os.path.exists(model['path']):

This comment has been minimized.

@takluyver

takluyver Dec 5, 2017

Member

API paths shouldn't be used as filesystem paths - you can't pass them to functions like os.path.exists(), because they probably don't start from the same directory where the tests are running. This check shouldn't be needed in any case.

@kirit93 kirit93 closed this Dec 5, 2017

@kirit93 kirit93 reopened this Dec 5, 2017

@kirit93

This comment has been minimized.

Copy link
Contributor Author

kirit93 commented Dec 5, 2017

@takluyver the GROUP=js/services tests fails with The command "pip install --upgrade setuptools wheel nose coverage codecov" failed and exited with 2 during .
Any ideas what this could be due to?

@takluyver

This comment has been minimized.

Copy link
Member

takluyver commented Dec 5, 2017

Looks like it's passed now. Sometimes there's a random connection failure while installing a package.

@takluyver
Copy link
Member

takluyver left a comment

Thanks, this is looking good.

@@ -522,11 +522,6 @@ def test_delete_dirs(self):
listing = self.api.list('/').json()['content']
self.assertEqual(listing, [])

def test_delete_non_empty_dir(self):

This comment has been minimized.

@takluyver

takluyver Dec 5, 2017

Member

Can we add a test that deleting a non-empty directory does work?

def test_delete_non_empty_dir(self):
# Test that non empty directory can be deleted
self.api.delete(u'å b')
# Assertion will pass only if self.api.delete does not throw and error

This comment has been minimized.

@takluyver

takluyver Dec 5, 2017

Member

A test doesn't have to have an assert - you can leave this off, and it will still fail if there's an error. When a test just checks that something runs without an error, that's a 'smoketest' (as in 'does this make smoke come out').

However, it would be good to check that it has actually been removed as well. Maybe copy some code from test_list_nonexistant_dir.

This comment has been minimized.

@kirit93

kirit93 Dec 5, 2017

Author Contributor

Oh okay. Sure, I'll make these changes!

@kirit93 kirit93 closed this Dec 5, 2017

@kirit93 kirit93 reopened this Dec 5, 2017

@kirit93

This comment has been minimized.

Copy link
Contributor Author

kirit93 commented Dec 5, 2017

@takluyver I've added the required tests. Is the PR okay to be merged?

@takluyver takluyver added this to the 5.3 milestone Dec 5, 2017

@takluyver

This comment has been minimized.

Copy link
Member

takluyver commented Dec 5, 2017

Yup, thanks!

@takluyver takluyver merged commit ae011a1 into jupyter:master Dec 5, 2017

4 checks passed

codecov/patch 50% of diff hit (target 0%)
Details
codecov/project 78.52% (-0.07%) compared to b1e5f72
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.