Skip to content

Commit

Permalink
#323: $ yapf --in-place --recursive oj onlinejudge setup.py tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kmyk committed Feb 25, 2019
1 parent 9e504c9 commit adb59e2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
6 changes: 4 additions & 2 deletions onlinejudge/service/toph.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ def login(self, get_credentials: onlinejudge.type.CredentialsProvider, session:
form = soup.find('form', class_='login-form')
log.debug('form: %s', str(form))
username, password = get_credentials()
form['action'] = '/login' # to avoid KeyError inside form.request method as Toph does not have any defined action
form['action'] = '/login' # to avoid KeyError inside form.request method as Toph does not have any defined action
form = utils.FormSender(form, url=resp.url)
form.set('handle', username)
form.set('password', password)
# post
resp = form.request(session)
resp.raise_for_status()

resp = utils.request('GET', url, session=session) # Toph's Location header is not getting the expected value
resp = utils.request('GET', url, session=session) # Toph's Location header is not getting the expected value
if resp.url != url:
log.success('Welcome, %s.', username)
return True
Expand Down Expand Up @@ -68,6 +68,7 @@ def from_url(cls, s: str) -> Optional['TophService']:
return cls()
return None


class TophProblem(onlinejudge.type.Problem):
def __init__(self, problem_id: str, kind: Optional[str] = None, contest_id: Optional[str] = None):
assert isinstance(problem_id, str)
Expand Down Expand Up @@ -168,5 +169,6 @@ def from_url(cls, s: str) -> Optional['TophProblem']:

return None


onlinejudge.dispatch.services += [TophService]
onlinejudge.dispatch.problems += [TophProblem]
1 change: 1 addition & 0 deletions tests/command_submit.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ def test_call_submit_worldcodesprint_mars_exploration(self):
with tests.utils.sandbox(files):
subprocess.check_call([ojtools, 's', '-y', '--no-open', url, 'a.py'], stdout=sys.stdout, stderr=sys.stderr)


class SubmitTophTest(unittest.TestCase):
@unittest.skipIf('CI' in os.environ, 'login is required')
def test_call_submit_copycat(self):
Expand Down

0 comments on commit adb59e2

Please sign in to comment.