-
Notifications
You must be signed in to change notification settings - Fork 593
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
add new thumbnail flag #336
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1295,3 +1295,51 @@ def test_download_chinese(self): | |
photo_modified_time.strftime('%Y-%m-%d %H:%M:%S')) | ||
|
||
assert result.exit_code == 0 | ||
|
||
def test_get_thumbnail_photo_of_album(self): | ||
base_dir = os.path.normpath(f"tests/fixtures/Photos/{inspect.stack()[0][3]}") | ||
if os.path.exists(base_dir): | ||
shutil.rmtree(base_dir) | ||
os.makedirs(base_dir) | ||
|
||
with vcr.use_cassette("tests/vcr_cassettes/listing_photos.yml"): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Best would be to add a new cassette for this test case. Creating a new cassette is pretty easy. Just use a new filename and run the test again. Make sure to remove personal data from the cassette before you check in. |
||
# Pass fixed client ID via environment variable | ||
|
||
def mock_raise_response_error(): | ||
raise PyiCloudAPIResponseError("Api Error", 100) | ||
|
||
with mock.patch.object(PhotosService, "_fetch_folders") as pa_photos_request: | ||
pa_photos_request.side_effect = mock_raise_response_error | ||
|
||
# Let the initial authenticate() call succeed, | ||
# but do nothing on the second try. | ||
orig_authenticate = PyiCloudService.authenticate | ||
|
||
def mocked_authenticate(self): | ||
if not hasattr(self, "already_authenticated"): | ||
orig_authenticate(self) | ||
setattr(self, "already_authenticated", True) | ||
|
||
with mock.patch("icloudpd.constants.WAIT_SECONDS", 0): | ||
with mock.patch.object( | ||
PyiCloudService, "authenticate", new=mocked_authenticate | ||
): | ||
runner = CliRunner(env={ | ||
"CLIENT_ID": "DE309E26-942E-11E8-92F5-14109FE0B321" | ||
}) | ||
result = runner.invoke( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You are running the script but don't have any assertions/tests. I suggest checking for the pictures you are expecting to be downloaded. Additionally you should do a negative test, p.e. run without your new parameter (so that more pictures are downloaded) and check that the second picture that would come is not been downloaded when run with |
||
main, | ||
[ | ||
"--username", | ||
"[email protected]", | ||
"--password", | ||
"password1", | ||
"--no-progress-bar", | ||
"--thumbnail", | ||
"--threads-num", | ||
1, | ||
"-d", | ||
base_dir, | ||
], | ||
) | ||
print_result_exception(result) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is
-a
required?