Skip to content

Commit 071731a

Browse files
committed
Initial creation of tests
1 parent 773d97e commit 071731a

4 files changed

Lines changed: 63 additions & 1 deletion

File tree

cfaster/__main__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def set_log_levels(level=logging.WARNING):
2222

2323
@group()
2424
@option('-v', '--verbose', is_flag=True, help='Output INFO level logs.')
25-
@version_option(__version__, message='v%(version)s')
25+
@version_option(__version__, message='%(version)s')
2626
def main_cmd(verbose):
2727
if verbose:
2828
set_log_levels(logging.INFO)

tests/__init__.py

Whitespace-only changes.

tests/test_main_cmd.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import re
2+
from click.testing import CliRunner
3+
from cfaster.__main__ import main_cmd
4+
5+
runner = CliRunner()
6+
7+
def test_version():
8+
result = runner.invoke(main_cmd, ['--version'])
9+
reg = r'\d+\.\d+\.\d+'
10+
match = re.match(reg, result.output)
11+
assert result.exit_code == 0
12+
assert match is not None

tests/test_scrape_cmd.py

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
from click.testing import CliRunner
2+
from cfaster.__main__ import scrape
3+
4+
runner = CliRunner()
5+
6+
invalid_urls = [
7+
'http://domain.com/problem',
8+
'https://domain.com/problem',
9+
'domain.com',
10+
'https://codeforces.com',
11+
'https://codeforces.com/contests',
12+
'sadaddsg.sda..sad',
13+
'www.codeforces.com/sad/dasdas/problem/A',
14+
'www.codeforces.com',
15+
]
16+
17+
valid_urls = [
18+
'https://codeforces.com/contest/1172/problem/A',
19+
'https://codeforces.com/contest/1172/problem/C1',
20+
'https://codeforces.com/contest/1172/problem/E',
21+
'https://codeforces.com/contest/1174/problem/B',
22+
'https://codeforces.com/contest/1174/problem/D',
23+
]
24+
25+
def test_no_url():
26+
result = runner.invoke(scrape)
27+
assert result.exit_code == 2
28+
29+
def test_invalid_urls():
30+
for invalid_url in invalid_urls:
31+
result = runner.invoke(scrape, invalid_url)
32+
assert result.exit_code != 0
33+
34+
def test_verbose_scrape():
35+
pass
36+
37+
def test_valid_url():
38+
pass
39+
40+
def test_count_inputs():
41+
pass
42+
43+
def test_count_outputs():
44+
pass
45+
46+
def test_inputs():
47+
pass
48+
49+
def test_outputs():
50+
pass

0 commit comments

Comments
 (0)