Skip to content

Commit

Permalink
Sort the unsorted RDFa values in the tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Cristi Constantin committed Jul 16, 2019
1 parent 8e69411 commit 3aaebd5
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
4 changes: 2 additions & 2 deletions extruct/opengraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ def extract_items(self, document, base_url=None):
namespaces.update(self.get_namespaces(head))
props = []
for el in head.xpath('meta[@property and @content]'):
prop = el.attrib['property']
val = el.attrib['content']
prop = el.attrib['property'].strip()
val = el.attrib['content'].strip()
if prop == '' or val == '':
continue
ns = prop.partition(':')[0]
Expand Down
8 changes: 4 additions & 4 deletions tests/samples/songkick/elysianfields.json
Original file line number Diff line number Diff line change
Expand Up @@ -231,18 +231,18 @@
],
"http://ogp.me/ns#description": [
{
"@value": "Buy tickets for an upcoming Elysian Fields concert near you. List of all Elysian Fields tickets and tour dates for 2017."
"@value": ""
},
{
"@value": ""
"@value": "Buy tickets for an upcoming Elysian Fields concert near you. List of all Elysian Fields tickets and tour dates for 2017."
}
],
"http://ogp.me/ns#image": [
{
"@value": "http://images.sk-static.com/images/media/img/col4/20100330-103600-169450.jpg"
"@value": "http://images.sk-static.com/SECONDARY_IMAGE.jpg"
},
{
"@value": "http://images.sk-static.com/SECONDARY_IMAGE.jpg"
"@value": "http://images.sk-static.com/images/media/img/col4/20100330-103600-169450.jpg"
}
],
"http://ogp.me/ns#site_name": [
Expand Down
7 changes: 4 additions & 3 deletions tests/test_extruct.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ def test_all(self):
body = get_testdata('songkick', 'elysianfields.html')
expected = json.loads(get_testdata('songkick', 'elysianfields.json').decode('UTF-8'))
data = extruct.extract(body, base_url='http://www.songkick.com/artists/236156-elysian-fields')
# See test_rdfa_not_preserving_order()
del data['rdfa'][0]['http://ogp.me/ns#image']
del expected['rdfa'][0]['http://ogp.me/ns#image']
for rdf in data['rdfa']:
for key, pairs in rdf.items():
if ':' in key and isinstance(pairs, list):
rdf[key] = sorted(pairs, key=lambda e: e["@value"])
self.assertEqual(jsonize_dict(data), expected)

@pytest.mark.xfail
Expand Down

0 comments on commit 3aaebd5

Please sign in to comment.