From 57f34c984ac7cdb8f82131fa5d6c9ee8713028b1 Mon Sep 17 00:00:00 2001 From: Angelo Gladding Date: Wed, 28 Jun 2023 17:10:41 -0700 Subject: [PATCH 1/3] Update tests to include alt texts by default --- test/test_parser.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/test_parser.py b/test/test_parser.py index 8b81490..96f8d40 100644 --- a/test/test_parser.py +++ b/test/test_parser.py @@ -441,9 +441,9 @@ def test_stop_implied_url(): def test_implied_nested_photo(): result = parse_fixture("implied_properties/implied_properties.html", url="http://bar.org") - assert result["items"][2]["properties"]["photo"][0] == "http://tommorris.org/photo.png" + assert result["items"][2]["properties"]["photo"][0] == {"alt": "", "value": "http://tommorris.org/photo.png"} assert result["items"][3]["properties"]["photo"][0] == "http://tommorris.org/photo.png" - assert result["items"][4]["properties"]["photo"][0] == "http://tommorris.org/photo.png" + assert result["items"][4]["properties"]["photo"][0] == {"alt": "Tom Morris", "value": "http://tommorris.org/photo.png"} # src="" is relative to the base url assert result["items"][6]["properties"]["photo"][0] == "http://bar.org" @@ -471,7 +471,7 @@ def test_implied_name_empty_alt(): 'properties': { 'name': ['@kylewmahan'], 'url': ['https://twitter.com/kylewmahan'], - 'photo': ['https://example.org/test.jpg'], + 'photo': [{'alt': '', 'value': 'https://example.org/test.jpg'}], }, } == hcard @@ -513,7 +513,7 @@ def test_implied_name_alt(): assert result["items"][0]["children"][0] == \ {'type': ['h-card'], 'properties': {'name': ['Avatar of Stephen'], - 'photo': ['avatar.jpg']}} + 'photo': [{'alt': 'Avatar of', 'value': 'avatar.jpg'}]}} def test_value_name_whitespace(): From b81dc2c19789f9833890b1aca0310a9a731ceee2 Mon Sep 17 00:00:00 2001 From: Angelo Gladding Date: Wed, 28 Jun 2023 17:20:08 -0700 Subject: [PATCH 2/3] Update additional tests --- test/test_parser.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/test_parser.py b/test/test_parser.py index 96f8d40..9c74b0d 100644 --- a/test/test_parser.py +++ b/test/test_parser.py @@ -455,7 +455,7 @@ def test_implied_nested_photo_alt_name(): def test_implied_image(): result = parse_fixture("implied_properties/implied_properties.html") - assert result["items"][4]["properties"]["photo"][0] == "http://tommorris.org/photo.png" + assert result["items"][4]["properties"]["photo"][0] == {"alt": "Tom Morris", "value": "http://tommorris.org/photo.png"} assert result["items"][4]["properties"]["name"][0] == "Tom Morris" def test_implied_name_empty_alt(): @@ -741,7 +741,7 @@ def test_photo_with_alt(): assert '/photo.jpg' == result['items'][0]['properties']['photo'][0] assert '/photo.jpg' == exp_result['items'][0]['properties']['photo'][0] - assert '/photo.jpg' == result['items'][1]['properties']['url'][0] + assert {'alt': 'alt text', 'value': '/photo.jpg'} == result['items'][1]['properties']['url'][0] assert '/photo.jpg' == exp_result['items'][1]['properties']['url'][0]['value'] assert 'alt text' == exp_result['items'][1]['properties']['url'][0]['alt'] From 92219c5bb28efda578befde286ee1484f8b480b1 Mon Sep 17 00:00:00 2001 From: Angelo Gladding Date: Wed, 28 Jun 2023 17:40:51 -0700 Subject: [PATCH 3/3] Update last of tests --- test/test_parser.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/test_parser.py b/test/test_parser.py index 9c74b0d..9115267 100644 --- a/test/test_parser.py +++ b/test/test_parser.py @@ -745,7 +745,7 @@ def test_photo_with_alt(): assert '/photo.jpg' == exp_result['items'][1]['properties']['url'][0]['value'] assert 'alt text' == exp_result['items'][1]['properties']['url'][0]['alt'] - assert '/photo.jpg' == result['items'][2]['properties']['in-reply-to'][0] + assert {'alt': '', 'value': '/photo.jpg'} == result['items'][2]['properties']['in-reply-to'][0] assert '/photo.jpg' == exp_result['items'][2]['properties']['in-reply-to'][0]['value'] assert '' == exp_result['items'][2]['properties']['in-reply-to'][0]['alt'] @@ -761,9 +761,9 @@ def test_photo_with_alt(): assert 'alt' not in exp_result['items'][3]['properties']['in-reply-to'][0] assert 'h-cite' in result['items'][4]['properties']['in-reply-to'][0]['type'] - assert '/photo.jpg' == result['items'][4]['properties']['in-reply-to'][0]['properties']['photo'][0] + assert {'alt': 'alt text', 'value': '/photo.jpg'} == result['items'][4]['properties']['in-reply-to'][0]['properties']['photo'][0] assert '/photo.jpg' == result['items'][4]['properties']['in-reply-to'][0]['value'] - assert 'alt' not in result['items'][4]['properties']['in-reply-to'][0] + assert 'alt' in result['items'][4]['properties']['in-reply-to'][0] assert 'h-cite' in exp_result['items'][4]['properties']['in-reply-to'][0]['type'] assert '/photo.jpg' == exp_result['items'][4]['properties']['in-reply-to'][0]['properties']['photo'][0]['value'] @@ -772,9 +772,9 @@ def test_photo_with_alt(): assert 'alt text' == exp_result['items'][4]['properties']['in-reply-to'][0]['alt'] assert 'h-cite' in result['items'][5]['properties']['in-reply-to'][0]['type'] - assert '/photo.jpg' == result['items'][5]['properties']['in-reply-to'][0]['properties']['photo'][0] + assert {'alt': '', 'value': '/photo.jpg'} == result['items'][5]['properties']['in-reply-to'][0]['properties']['photo'][0] assert '/photo.jpg' == result['items'][5]['properties']['in-reply-to'][0]['value'] - assert 'alt' not in result['items'][5]['properties']['in-reply-to'][0] + assert 'alt' in result['items'][5]['properties']['in-reply-to'][0] assert 'h-cite' in exp_result['items'][5]['properties']['in-reply-to'][0]['type'] assert '/photo.jpg' == exp_result['items'][5]['properties']['in-reply-to'][0]['properties']['photo'][0]['value']