Skip to content

Commit 0501afe

Browse files
committed
add executable integration tests for new remote font file support
1 parent 000260d commit 0501afe

File tree

1 file changed

+39
-1
lines changed

1 file changed

+39
-1
lines changed

tests/test_main.py

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@
1616
ROBOTO_UDIFF_HEADPOSTONLY_EXPECTED_PATH = os.path.join("tests", "testfiles", "roboto_udiff_headpostonly_expected.txt")
1717
ROBOTO_UDIFF_EXCLUDE_HEADPOST_EXPECTED_PATH = os.path.join("tests", "testfiles", "roboto_udiff_ex_headpost_expected.txt")
1818

19+
ROBOTO_BEFORE_URL = "https://github.com/source-foundry/fdiff/raw/master/tests/testfiles/Roboto-Regular.subset1.ttf"
20+
ROBOTO_AFTER_URL = "https://github.com/source-foundry/fdiff/raw/master/tests/testfiles/Roboto-Regular.subset2.ttf"
21+
22+
URL_404 = "https://httpbin.org/status/404"
23+
1924

2025
# Setup: define the expected diff text for unified diff
2126
with open(ROBOTO_UDIFF_EXPECTED_PATH, "r") as robo_udiff:
@@ -87,7 +92,7 @@ def test_main_include_exclude_defined_simultaneously(capsys):
8792
# Unified diff integration tests
8893
#
8994

90-
def test_main_run_unified_default(capsys):
95+
def test_main_run_unified_default_local_files(capsys):
9196
args = [ROBOTO_BEFORE_PATH, ROBOTO_AFTER_PATH]
9297

9398
run(args)
@@ -108,6 +113,39 @@ def test_main_run_unified_default(capsys):
108113
assert line == expected_string_list[x]
109114

110115

116+
def test_main_run_unified_default_remote_files(capsys):
117+
args = [ROBOTO_BEFORE_URL, ROBOTO_AFTER_URL]
118+
119+
run(args)
120+
captured = capsys.readouterr()
121+
122+
res_string_list = captured.out.split("\n")
123+
expected_string_list = ROBOTO_UDIFF_EXPECTED.split("\n")
124+
125+
# have to handle the tests for the top two file path lines
126+
# differently than the rest of the comparisons because
127+
# the time is defined using local platform settings
128+
# which makes tests fail on different remote CI testing services
129+
for x, line in enumerate(res_string_list):
130+
# treat top two lines of the diff as comparison of first 10 chars only
131+
if x == 0:
132+
assert line[0:9] == "--- https"
133+
elif x == 1:
134+
assert line[0:9] == "+++ https"
135+
else:
136+
assert line == expected_string_list[x]
137+
138+
139+
def test_main_run_unified_default_404(capsys):
140+
with pytest.raises(SystemExit):
141+
args = [URL_404, URL_404]
142+
143+
run(args)
144+
captured = capsys.readouterr()
145+
assert captured.out.startswith("[*] ERROR:")
146+
assert "HTTP status code 404" in captured.out
147+
148+
111149
def test_main_run_unified_color(capsys):
112150
args = ["-c", ROBOTO_BEFORE_PATH, ROBOTO_AFTER_PATH]
113151

0 commit comments

Comments
 (0)