Override __str__ for endpoint f-strings
By default, f-strings use __str__ not __repr__, unless supplied with a "!r" at the end of the str. Rather than going through and making the strings work for the overridden __repr__ for endpoints, it's easier just to convert the method over to __str__. Also cleaned up some broken routes and formatting.
This commit is contained in:
parent
ba7409f230
commit
74e9317053
|
@ -15,8 +15,9 @@ class Endpoint(Enum):
|
|||
element = 'element'
|
||||
window = 'window'
|
||||
|
||||
def __repr__(self):
|
||||
def __str__(self):
|
||||
return self.value
|
||||
|
||||
def in_path(self, path: str) -> bool:
|
||||
return path.startswith(self.value)
|
||||
return path.startswith(self.value) or \
|
||||
path.startswith(f'/{self.value}')
|
||||
|
|
|
@ -176,11 +176,11 @@ def home():
|
|||
return redirect(url_for('.index'))
|
||||
|
||||
|
||||
@app.route(f'{Endpoint.session}/<session_id>', methods=['GET', 'PUT', 'POST'])
|
||||
@app.route(f'/{Endpoint.session}/<session_id>', methods=['GET', 'PUT', 'POST'])
|
||||
def session_check(session_id):
|
||||
if 'uuid' in session and session['uuid'] == session_id:
|
||||
session['valid'] = True
|
||||
return redirect(request.args.get('follow'))
|
||||
return redirect(request.args.get('follow'), code=307)
|
||||
else:
|
||||
follow_url = request.args.get('follow')
|
||||
req = PreparedRequest()
|
||||
|
|
|
@ -9,7 +9,8 @@ def test_autocomplete_get(client):
|
|||
|
||||
|
||||
def test_autocomplete_post(client):
|
||||
rv = client.post(f'/{Endpoint.autocomplete}', data=dict(q='the+cat+in+the'))
|
||||
rv = client.post(f'/{Endpoint.autocomplete}',
|
||||
data=dict(q='the+cat+in+the'))
|
||||
assert rv._status_code == 200
|
||||
assert len(rv.data) >= 1
|
||||
assert b'the cat in the hat' in rv.data
|
||||
|
|
Loading…
Reference in New Issue
Block a user