Skip to content

Commit 725425d

Browse files
committed
new tests
1 parent cb8d608 commit 725425d

File tree

2 files changed

+87
-0
lines changed

2 files changed

+87
-0
lines changed

tests/test_commands.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
4+
import sys
5+
import pytest
6+
7+
from fontline.commands import get_linegap_percent_filepath
8+
9+
10+
def test_commands_function_getlg_percent_filepath():
11+
response = get_linegap_percent_filepath("Test.ttf", "20")
12+
assert response == "Test-linegap20.ttf"
13+

tests/test_percent_cmd.py

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
4+
import sys
5+
import pytest
6+
import os.path
7+
import os
8+
9+
# ///////////////////////////////////////////////////////
10+
#
11+
# report sub-command tests
12+
#
13+
# ///////////////////////////////////////////////////////
14+
15+
16+
def test_percent_cmd_too_few_args(capsys):
17+
with pytest.raises(SystemExit):
18+
from fontline.app import main
19+
sys.argv = ['font-line', 'percent']
20+
main()
21+
out, err = capsys.readouterr()
22+
assert err == "[font-line] ERROR: Not enough arguments."
23+
24+
25+
def test_percent_cmd_too_few_args_two(capsys):
26+
with pytest.raises(SystemExit):
27+
from fontline.app import main
28+
sys.argv = ['font-line', 'percent', '10']
29+
main()
30+
out, err = capsys.readouterr()
31+
assert err == "[font-line] ERROR: Not enough arguments."
32+
33+
34+
def test_percent_cmd_percent_arg_not_integer(capsys):
35+
with pytest.raises(SystemExit):
36+
from fontline.app import main
37+
sys.argv = ['font-line', 'percent', 'astring', 'Test.ttf']
38+
main()
39+
out, err = capsys.readouterr()
40+
assert err.startswith("[font-line] ERROR: You entered ") is True
41+
42+
43+
def test_percent_cmd_percent_arg_less_zero(capsys):
44+
with pytest.raises(SystemExit):
45+
from fontline.app import main
46+
sys.argv = ['font-line', 'percent', '-1', 'Test.ttf']
47+
main()
48+
out, err = capsys.readouterr()
49+
assert err == "[font-line] ERROR: Please enter a percent value that is greater than zero."
50+
51+
52+
def test_percent_cmd_percent_arg_over_hundred(capsys):
53+
from fontline.app import main
54+
sys.argv = ['font-line', 'percent', '200', 'Test.ttf']
55+
main()
56+
out, err = capsys.readouterr()
57+
assert out.startswith("[font-line] Warning: You entered a percent value over 100%.")
58+
59+
60+
def test_percent_cmd_font_file_missing(capsys):
61+
from fontline.app import main
62+
sys.argv = ['font-line', 'percent', '20', 'Test.ttf']
63+
main()
64+
out, err = capsys.readouterr()
65+
assert ("does not appear to be a valid filepath" in err) is True
66+
67+
68+
def test_percent_cmd_font_file_wrong_filetype(capsys):
69+
from fontline.app import main
70+
testfile_path = os.path.join("tests", "testingfiles", "bogus.txt")
71+
sys.argv = ['font-line', 'percent', '20', testfile_path]
72+
main()
73+
out, err = capsys.readouterr()
74+
assert ("does not appear to be a supported font file type." in err) is True

0 commit comments

Comments
 (0)