Skip to content

Commit

Permalink
Raises error if no sample found.
Browse files Browse the repository at this point in the history
  • Loading branch information
fukatani committed Dec 3, 2019
1 parent 7a8c94a commit fabbc06
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
3 changes: 3 additions & 0 deletions onlinejudge/_implementation/command/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ def download(args: 'argparse.Namespace') -> None:
else:
samples = problem.download_sample_cases(session=sess)

if not samples:
raise onlinejudge.type.SampleParseError("Sample not found")

# append the history for submit command
if not args.dry_run and is_default_format:
history = onlinejudge._implementation.download_history.DownloadHistory()
Expand Down
5 changes: 5 additions & 0 deletions tests/command_download_invalid.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import requests.exceptions
import tests.command_download

from onlinejudge.type import SampleParseError


class DownloadInvalid(unittest.TestCase):
def snippet_call_download_raises(self, *args, **kwargs):
Expand All @@ -14,6 +16,9 @@ def snippet_call_download_twice(self, *args, **kwargs):
def test_call_download_invalid(self):
self.snippet_call_download_raises(requests.exceptions.InvalidURL, 'https://not_exist_contest.jp/tasks/001_a')

def test_call_download_no_sample_found(self):
self.snippet_call_download_raises(SampleParseError, 'https://atcoder.jp/contests/tenka1-2013-quala/tasks/tenka1_2013_qualA_a')

def test_call_download_twice(self):
self.snippet_call_download_twice('https://atcoder.jp/contests/abc114/tasks/abc114_c', 'https://atcoder.jp/contests/abc003/tasks/abc003_4', [
{
Expand Down

0 comments on commit fabbc06

Please sign in to comment.