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

Raise NotFoundError if no daily build can be found for latest build date #672

Merged
merged 6 commits into from
May 6, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions mozdownload/scraper.py
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,8 @@ def get_latest_build_date(self):
months.entries[-1] + '/')
parser = self._create_directory_parser(url)
parser.entries = parser.filter(r'.*%s' % self.platform_regex)
if not parser.entries:
raise errors.NotSupportedError('No builds have been found')
Copy link
Contributor

Choose a reason for hiding this comment

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

I just noticed that this should be a NotFoundError. Looks like it slipped through in my last review. Can you please update both the code here and the test?

Beside that we probably should indeed have a NotSupportedError thrown when an unsupported platform has been specified. But this check should be done as early as possible when we know the application and which kind of platform is selected. I would suggest that you create a separate PR for that and we leave open the issue even with this PR merged.

parser.entries.sort()

date = ''.join(parser.entries[-1].split('-')[:6])
Expand Down
19 changes: 19 additions & 0 deletions tests/daily_scraper/test_invalid_platform.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env python

# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
# You can obtain one at http://mozilla.org/MPL/2.0/.

import pytest

from mozdownload import DailyScraper
import mozdownload.errors as errors

@pytest.mark.parametrize('args', [
({'application': 'fenix', 'platform': 'mac'}),
Copy link
Contributor

Choose a reason for hiding this comment

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

Please note that with the follow-up PR for NotSupportedError this will change given that mac is a not supported platform. But I'm fine with landing this for now, given that it only affects Fenix builds.

])
def test_invalid_platform(httpd, tmpdir, args):
"""Testing download scenarios with invalid platform parameters for DailyScraper"""

with pytest.raises(errors.NotSupportedError):
DailyScraper(destination=str(tmpdir), base_url=httpd.get_url(), **args)