Skip to content

Commit

Permalink
feat(meta): do not jsonized version meta
Browse files Browse the repository at this point in the history
  • Loading branch information
s-pace committed May 27, 2020
1 parent f4d9ff5 commit 2b452ff
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
2 changes: 1 addition & 1 deletion scraper/src/strategies/default_strategy.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ def get_records_from_dom(self, current_page_url=None):
record[name] = content

if name == "version":
record[name] = str(record[name])

This comment has been minimized.

Copy link
@JOHNMDAY-CREATE

JOHNMDAY-CREATE Oct 7, 2020

str(content)

record[name] = str(content)

if current_page_url is not None:
# Add variables to the record
Expand Down
31 changes: 31 additions & 0 deletions scraper/src/tests/default_strategy/meta_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,37 @@ def test_meta_numbered_version(self):
assert actual[0]['version'] == "1.0"
assert actual[1]['version'] != 1

def test_meta_decimal_version(self):
# Given
strategy = get_strategy({
'selectors': {
'lvl0': "h1",
'content': 'p'
}
})
strategy.dom = lxml.html.fromstring("""
<html>
<header>
<meta name="docsearch:version" content='5.20'>
</header>
<body>
<h1>Foo</h1>
<p>text</p>
<h2>Bar</h2>
<h3>Baz</h3>
</body>
</html>
""")

# When
actual = strategy.get_records_from_dom()

# Then

assert len(actual) == 2
assert actual[0]['version'] == "5.20"
assert actual[1]['version'] != 5.2

def test_meta_escaped_string(self):
# Given
strategy = get_strategy({
Expand Down

0 comments on commit 2b452ff

Please sign in to comment.