-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #288 from kmyk/issue/200
#200 add --check option to login command
- Loading branch information
Showing
8 changed files
with
89 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import os | ||
import subprocess | ||
import sys | ||
import time | ||
import unittest | ||
|
||
import tests.utils | ||
|
||
|
||
class LoginTest(unittest.TestCase): | ||
def snippet_call_login_check_failure(self, url): | ||
ojtools = os.path.abspath('oj') | ||
with tests.utils.sandbox(files=[]) as tempdir: | ||
env = dict(**os.environ) | ||
env['HOME'] = tempdir | ||
self.assertRaises | ||
proc = subprocess.run([ojtools, 'login', '--check', url], env=env, stdout=sys.stdout, stderr=sys.stderr) | ||
self.assertEqual(proc.returncode, 1) | ||
|
||
def test_call_login_check_atcoder_failure(self): | ||
self.snippet_call_login_check_failure('https://atcoder.jp/') | ||
|
||
def test_call_login_check_codeforces_failure(self): | ||
self.snippet_call_login_check_failure('https://codeforces.com/') | ||
|
||
def test_call_login_check_yukicoder_failure(self): | ||
self.snippet_call_login_check_failure('https://yukicoder.me/') | ||
|
||
@unittest.skipIf('CI' in os.environ, 'login is required') | ||
def test_call_login_check_atcoder_success(self): | ||
ojtools = os.path.abspath('oj') | ||
subprocess.check_call([ojtools, 'login', '--check', 'https://atcoder.jp/'], stdout=sys.stdout, stderr=sys.stderr) | ||
|
||
@unittest.skipIf('CI' in os.environ, 'login is required') | ||
def test_call_login_check_codeforces_success(self): | ||
ojtools = os.path.abspath('oj') | ||
subprocess.check_call([ojtools, 'login', '--check', 'https://codeforces.com/'], stdout=sys.stdout, stderr=sys.stderr) | ||
|
||
@unittest.skipIf('CI' in os.environ, 'login is required') | ||
def test_call_login_check_yukicoder_success(self): | ||
ojtools = os.path.abspath('oj') | ||
subprocess.check_call([ojtools, 'login', '--check', 'https://yukicoder.me/'], stdout=sys.stdout, stderr=sys.stderr) |