16
16
ROBOTO_UDIFF_HEADPOSTONLY_EXPECTED_PATH = os .path .join ("tests" , "testfiles" , "roboto_udiff_headpostonly_expected.txt" )
17
17
ROBOTO_UDIFF_EXCLUDE_HEADPOST_EXPECTED_PATH = os .path .join ("tests" , "testfiles" , "roboto_udiff_ex_headpost_expected.txt" )
18
18
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
+
19
24
20
25
# Setup: define the expected diff text for unified diff
21
26
with open (ROBOTO_UDIFF_EXPECTED_PATH , "r" ) as robo_udiff :
@@ -87,7 +92,7 @@ def test_main_include_exclude_defined_simultaneously(capsys):
87
92
# Unified diff integration tests
88
93
#
89
94
90
- def test_main_run_unified_default (capsys ):
95
+ def test_main_run_unified_default_local_files (capsys ):
91
96
args = [ROBOTO_BEFORE_PATH , ROBOTO_AFTER_PATH ]
92
97
93
98
run (args )
@@ -108,6 +113,39 @@ def test_main_run_unified_default(capsys):
108
113
assert line == expected_string_list [x ]
109
114
110
115
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
+
111
149
def test_main_run_unified_color (capsys ):
112
150
args = ["-c" , ROBOTO_BEFORE_PATH , ROBOTO_AFTER_PATH ]
113
151
0 commit comments