Add ability to configure site alts w/ env vars
Site alternatives (i.e. twitter.com -> nitter.net) can now be configured using environment variables: WHOOGLE_ALT_TW='nitter.net' # twitter alt WHOOGLE_ALT_YT='invidio.us' # youtube alt WHOOGLE_ALT_IG='bibliogram.art/u' # instagram alt Updated testing to confirm results have been modified.
This commit is contained in:
parent
44a5da1895
commit
d2adfb772c
|
@ -1,4 +1,5 @@
|
|||
from bs4 import BeautifulSoup
|
||||
import os
|
||||
import urllib.parse as urlparse
|
||||
from urllib.parse import parse_qs
|
||||
|
||||
|
@ -17,9 +18,9 @@ BLACKLIST = [
|
|||
]
|
||||
|
||||
SITE_ALTS = {
|
||||
'twitter.com': 'nitter.net',
|
||||
'youtube.com': 'invidious.snopyta.org',
|
||||
'instagram.com': 'bibliogram.art/u'
|
||||
'twitter.com': os.getenv('WHOOGLE_ALT_TW', 'nitter.net'),
|
||||
'youtube.com': os.getenv('WHOOGLE_ALT_YT', 'invidious.snopyta.org'),
|
||||
'instagram.com': os.getenv('WHOOGLE_ALT_IG', 'bibliogram.art/u')
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,17 @@
|
|||
from app import app
|
||||
from app.models.config import Config
|
||||
from app.utils.session_utils import generate_user_keys
|
||||
import pytest
|
||||
import random
|
||||
|
||||
demo_config = {
|
||||
'near': random.choice(['Seattle', 'New York', 'San Francisco']),
|
||||
'dark_mode': str(random.getrandbits(1)),
|
||||
'nojs': str(random.getrandbits(1)),
|
||||
'lang_interface': random.choice(Config.LANGUAGES)['value'],
|
||||
'lang_search': random.choice(Config.LANGUAGES)['value'],
|
||||
'ctry': random.choice(Config.COUNTRIES)['value']
|
||||
}
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
|
|
|
@ -3,6 +3,8 @@ from app.filter import Filter
|
|||
from app.utils.session_utils import generate_user_keys
|
||||
from datetime import datetime
|
||||
from dateutil.parser import *
|
||||
import json
|
||||
import os
|
||||
|
||||
|
||||
def get_search_results(data):
|
||||
|
@ -43,6 +45,18 @@ def test_post_results(client):
|
|||
assert len(get_search_results(rv.data)) <= 15
|
||||
|
||||
|
||||
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))
|
||||
assert json.loads(client.get('/config').data)['alts']
|
||||
|
||||
rv = client.post('/search', data=dict(q='twitter official account'))
|
||||
assert b'twitter.com/Twitter' not in rv.data
|
||||
assert b'nitter.net/Twitter' in rv.data
|
||||
|
||||
|
||||
def test_recent_results(client):
|
||||
times = {
|
||||
'past year': 365,
|
||||
|
|
|
@ -1,15 +1,6 @@
|
|||
from app.models.config import Config
|
||||
import json
|
||||
import random
|
||||
|
||||
demo_config = {
|
||||
'near': random.choice(['Seattle', 'New York', 'San Francisco']),
|
||||
'dark_mode': str(random.getrandbits(1)),
|
||||
'nojs': str(random.getrandbits(1)),
|
||||
'lang_interface': random.choice(Config.LANGUAGES)['value'],
|
||||
'lang_search': random.choice(Config.LANGUAGES)['value'],
|
||||
'ctry': random.choice(Config.COUNTRIES)['value']
|
||||
}
|
||||
from test.conftest import demo_config
|
||||
|
||||
|
||||
def test_main(client):
|
||||
|
@ -58,4 +49,4 @@ def test_config(client):
|
|||
def test_opensearch(client):
|
||||
rv = client.get('/opensearch.xml')
|
||||
assert rv._status_code == 200
|
||||
assert 'Whoogle' in str(rv.data)
|
||||
assert '<ShortName>Whoogle</ShortName>' in str(rv.data)
|
||||
|
|
Loading…
Reference in New Issue
Block a user