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

Only delete files that were successfully downloaded #625

Merged
merged 4 commits into from
Apr 20, 2023
Merged

Only delete files that were successfully downloaded #625

merged 4 commits into from
Apr 20, 2023

Conversation

jfsimoneau
Copy link
Contributor

No description provided.

@AndreyNikiforov
Copy link
Collaborator

@jfsimoneau do you have an idea what tests can a good indicator that new functionality is fixing the issue and working correctly? That would be very helpful for maintaining the app going forward.

@jfsimoneau
Copy link
Contributor Author

@AndreyNikiforov I admit I did not take the time to see how we could simulate a failed download in the unit tests. I will take a look later today.

@jfsimoneau
Copy link
Contributor Author

I added a test with a failed download. This should fix #614.

f"INFO Downloading {os.path.join(base_dir, os.path.normpath('2018/07/31/IMG_7409.JPG'))}",
self._caplog.text,
)
self.assertNotIn(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a way to confirm skipping deletion call without/in addition to relying on logs? It would be beneficial to separate logic check from logging check, so we can change one without breaking tests for the other.

Note the most test still combine log and state/file/api checks and I hope that can be changes over time too.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wanted to mock the internal delete_photo() function to see if it was called, but it seems it's not accessible. The best way I found to make that tests is to craft a cassette to simulate a bad request. Because of that bad request, the delete is never called so the cassette is complete.

@AndreyNikiforov AndreyNikiforov merged commit 3ed662d into icloud-photos-downloader:master Apr 20, 2023
14 checks passed
@jfsimoneau jfsimoneau deleted the delete-after-download-success branch April 20, 2023 22:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants