Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Update tests to include alt texts by default #190

Merged
merged 3 commits into from
Jun 29, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions test/test_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -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():
Expand All @@ -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

Expand Down Expand Up @@ -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():
Expand Down Expand Up @@ -741,11 +741,11 @@ 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']

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']

Expand All @@ -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']
Expand All @@ -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']
Expand Down