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

Add consistent build number error notification for scrapers (#121) #677

Merged
merged 7 commits into from
May 6, 2024
9 changes: 8 additions & 1 deletion mozdownload/scraper.py
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,10 @@ def get_build_info_for_date(self, date, build_index=None):
build_index -= 1
if not build_index or self.is_build_dir(build):
break

if build_index >= len(parser.entries):
raise errors.NotFoundError('Specified build number has not been found ', url)

self.logger.info('Selected build: %s' % parser.entries[build_index])

return (parser.entries, build_index)
Expand Down Expand Up @@ -762,7 +766,7 @@ def get_build_info(self):
self.build_index = 0
self.logger.info('Selected build: build%s' % self.build_number)
else:
raise errors.NotSupportedError('Selected build not available')
raise errors.NotFoundError('Specified build number has not been found ', url)

@property
def candidate_build_list_regex(self):
Expand Down Expand Up @@ -985,6 +989,9 @@ def get_build_info_for_index(self, build_index=None):
if not build_index or self.is_build_dir(build):
break

if build_index >= len(parser.entries):
raise errors.NotFoundError('Specified build number has not been found ', url)

piri-p marked this conversation as resolved.
Show resolved Hide resolved
self.logger.info('Selected build: %s' % parser.entries[build_index])

return (parser.entries, build_index)
Expand Down
19 changes: 19 additions & 0 deletions tests/daily_scraper/test_invalid_build.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': 'firefox', 'date': '2013-07-02', 'build_number': 3}),
])
def test_invalid_build(httpd, tmpdir, args):
"""Testing download scenarios with invalid branch parameters for DailyScraper"""

with pytest.raises(errors.NotFoundError):
DailyScraper(destination=str(tmpdir), base_url=httpd.get_url(), **args)
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@ def test_invalid_build_number(httpd, tmpdir):

args = {'application': 'firefox', 'build_number': '2', 'platform': 'linux', 'version': '23.0.1'}

with pytest.raises(errors.NotSupportedError):
with pytest.raises(errors.NotFoundError):
ReleaseCandidateScraper(destination=tmpdir, base_url=httpd.get_url(), **args)
20 changes: 20 additions & 0 deletions tests/tinderbox_scraper/test_invalid_build_tinderbox.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/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 TinderboxScraper
import mozdownload.errors as errors


@pytest.mark.parametrize("args", [
({'application': 'firefox', 'branch': 'mozilla-central', 'build_number': '4', 'date': '2013-07-23'}),
])
def test_invalid_build_tinderbox(httpd, tmpdir, args):
"""Testing download scenarios with invalid parameters for TinderboxScraper"""

with pytest.raises(errors.NotFoundError):
TinderboxScraper(destination=str(tmpdir), base_url=httpd.get_url(), **args)
Loading