Fix nojs lxml constructor

The BeautifulSoup constructur in gen_nojs needed to explicitly set
features='lxml' to silence a warning from the library.

Also temporarily disabled the site alts test since the results are too
unreliable. This should be moved to a unit test instead.
main
Ben Busby 2020-12-11 19:21:32 -05:00
parent dad80ff8fb
commit 5b5c2588ed
No known key found for this signature in database
GPG Key ID: 3B08611DF6E62ED2
2 changed files with 11 additions and 9 deletions

View File

@ -72,7 +72,7 @@ def filter_link_args(query_link):
def gen_nojs(sibling): def gen_nojs(sibling):
nojs_link = BeautifulSoup().new_tag('a') nojs_link = BeautifulSoup(features='lxml').new_tag('a')
nojs_link['href'] = '/window?location=' + sibling['href'] nojs_link['href'] = '/window?location=' + sibling['href']
nojs_link['style'] = 'display:block;width:100%;' nojs_link['style'] = 'display:block;width:100%;'
nojs_link.string = 'NoJS Link: ' + nojs_link['href'] nojs_link.string = 'NoJS Link: ' + nojs_link['href']

View File

@ -45,16 +45,18 @@ def test_post_results(client):
assert len(get_search_results(rv.data)) <= 15 assert len(get_search_results(rv.data)) <= 15
def test_site_alts(client): # TODO: Unit test the site alt method instead -- the results returned
rv = client.post('/search', data=dict(q='twitter official account')) # are too unreliable for this test in particular.
assert b'twitter.com/Twitter' in rv.data # def test_site_alts(client):
# rv = client.post('/search', data=dict(q='twitter official account'))
# assert b'twitter.com/Twitter' in rv.data
client.post('/config', data=dict(alts=True)) # client.post('/config', data=dict(alts=True))
assert json.loads(client.get('/config').data)['alts'] # assert json.loads(client.get('/config').data)['alts']
rv = client.post('/search', data=dict(q='twitter official account')) # rv = client.post('/search', data=dict(q='twitter official account'))
assert b'twitter.com/Twitter' not in rv.data # assert b'twitter.com/Twitter' not in rv.data
assert b'nitter.net/Twitter' in rv.data # assert b'nitter.net/Twitter' in rv.data
def test_recent_results(client): def test_recent_results(client):