16
16
_get_html_media_encodings ,
17
17
decode_body ,
18
18
parse_html_to_open_graph ,
19
- rebase_url ,
20
19
summarize_paragraphs ,
21
20
)
22
21
@@ -161,7 +160,7 @@ def test_simple(self) -> None:
161
160
"""
162
161
163
162
tree = decode_body (html , "http://example.com/test.html" )
164
- og = parse_html_to_open_graph (tree , "http://example.com/test.html" )
163
+ og = parse_html_to_open_graph (tree )
165
164
166
165
self .assertEqual (og , {"og:title" : "Foo" , "og:description" : "Some text." })
167
166
@@ -177,7 +176,7 @@ def test_comment(self) -> None:
177
176
"""
178
177
179
178
tree = decode_body (html , "http://example.com/test.html" )
180
- og = parse_html_to_open_graph (tree , "http://example.com/test.html" )
179
+ og = parse_html_to_open_graph (tree )
181
180
182
181
self .assertEqual (og , {"og:title" : "Foo" , "og:description" : "Some text." })
183
182
@@ -196,7 +195,7 @@ def test_comment2(self) -> None:
196
195
"""
197
196
198
197
tree = decode_body (html , "http://example.com/test.html" )
199
- og = parse_html_to_open_graph (tree , "http://example.com/test.html" )
198
+ og = parse_html_to_open_graph (tree )
200
199
201
200
self .assertEqual (
202
201
og ,
@@ -218,7 +217,7 @@ def test_script(self) -> None:
218
217
"""
219
218
220
219
tree = decode_body (html , "http://example.com/test.html" )
221
- og = parse_html_to_open_graph (tree , "http://example.com/test.html" )
220
+ og = parse_html_to_open_graph (tree )
222
221
223
222
self .assertEqual (og , {"og:title" : "Foo" , "og:description" : "Some text." })
224
223
@@ -232,7 +231,7 @@ def test_missing_title(self) -> None:
232
231
"""
233
232
234
233
tree = decode_body (html , "http://example.com/test.html" )
235
- og = parse_html_to_open_graph (tree , "http://example.com/test.html" )
234
+ og = parse_html_to_open_graph (tree )
236
235
237
236
self .assertEqual (og , {"og:title" : None , "og:description" : "Some text." })
238
237
@@ -247,7 +246,7 @@ def test_h1_as_title(self) -> None:
247
246
"""
248
247
249
248
tree = decode_body (html , "http://example.com/test.html" )
250
- og = parse_html_to_open_graph (tree , "http://example.com/test.html" )
249
+ og = parse_html_to_open_graph (tree )
251
250
252
251
self .assertEqual (og , {"og:title" : "Title" , "og:description" : "Some text." })
253
252
@@ -262,7 +261,7 @@ def test_missing_title_and_broken_h1(self) -> None:
262
261
"""
263
262
264
263
tree = decode_body (html , "http://example.com/test.html" )
265
- og = parse_html_to_open_graph (tree , "http://example.com/test.html" )
264
+ og = parse_html_to_open_graph (tree )
266
265
267
266
self .assertEqual (og , {"og:title" : None , "og:description" : "Some text." })
268
267
@@ -290,7 +289,7 @@ def test_xml(self) -> None:
290
289
<head><title>Foo</title></head><body>Some text.</body></html>
291
290
""" .strip ()
292
291
tree = decode_body (html , "http://example.com/test.html" )
293
- og = parse_html_to_open_graph (tree , "http://example.com/test.html" )
292
+ og = parse_html_to_open_graph (tree )
294
293
self .assertEqual (og , {"og:title" : "Foo" , "og:description" : "Some text." })
295
294
296
295
def test_invalid_encoding (self ) -> None :
@@ -304,7 +303,7 @@ def test_invalid_encoding(self) -> None:
304
303
</html>
305
304
"""
306
305
tree = decode_body (html , "http://example.com/test.html" , "invalid-encoding" )
307
- og = parse_html_to_open_graph (tree , "http://example.com/test.html" )
306
+ og = parse_html_to_open_graph (tree )
308
307
self .assertEqual (og , {"og:title" : "Foo" , "og:description" : "Some text." })
309
308
310
309
def test_invalid_encoding2 (self ) -> None :
@@ -319,7 +318,7 @@ def test_invalid_encoding2(self) -> None:
319
318
</html>
320
319
"""
321
320
tree = decode_body (html , "http://example.com/test.html" )
322
- og = parse_html_to_open_graph (tree , "http://example.com/test.html" )
321
+ og = parse_html_to_open_graph (tree )
323
322
self .assertEqual (og , {"og:title" : "ÿÿ Foo" , "og:description" : "Some text." })
324
323
325
324
def test_windows_1252 (self ) -> None :
@@ -333,7 +332,7 @@ def test_windows_1252(self) -> None:
333
332
</html>
334
333
"""
335
334
tree = decode_body (html , "http://example.com/test.html" )
336
- og = parse_html_to_open_graph (tree , "http://example.com/test.html" )
335
+ og = parse_html_to_open_graph (tree )
337
336
self .assertEqual (og , {"og:title" : "ó" , "og:description" : "Some text." })
338
337
339
338
@@ -448,34 +447,3 @@ def test_unknown_invalid(self) -> None:
448
447
'text/html; charset="invalid"' ,
449
448
)
450
449
self .assertEqual (list (encodings ), ["utf-8" , "cp1252" ])
451
-
452
-
453
- class RebaseUrlTestCase (unittest .TestCase ):
454
- def test_relative (self ) -> None :
455
- """Relative URLs should be resolved based on the context of the base URL."""
456
- self .assertEqual (
457
- rebase_url ("subpage" , "https://example.com/foo/" ),
458
- "https://example.com/foo/subpage" ,
459
- )
460
- self .assertEqual (
461
- rebase_url ("sibling" , "https://example.com/foo" ),
462
- "https://example.com/sibling" ,
463
- )
464
- self .assertEqual (
465
- rebase_url ("/bar" , "https://example.com/foo/" ),
466
- "https://example.com/bar" ,
467
- )
468
-
469
- def test_absolute (self ) -> None :
470
- """Absolute URLs should not be modified."""
471
- self .assertEqual (
472
- rebase_url ("https://alice.com/a/" , "https://example.com/foo/" ),
473
- "https://alice.com/a/" ,
474
- )
475
-
476
- def test_data (self ) -> None :
477
- """Data URLs should not be modified."""
478
- self .assertEqual (
479
- rebase_url ("data:,Hello%2C%20World%21" , "https://example.com/foo/" ),
480
- "data:,Hello%2C%20World%21" ,
481
- )
0 commit comments