Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_padDigits14(expected, input):
assert expected == util.padDigits14(input)
def test_padDigits14_inalid(input):
with pytest.raises(ValueError):
util.padDigits14(input, validate=True)
def showMemento(urir, datetime):
try:
datetime = ipwbUtils.padDigits14(datetime, validate=True)
except ValueError as e:
msg = 'Expected a 4-14 digits valid datetime: {}'.format(datetime)
return Response(msg, status=400)
resolvedMemento = resolveMemento(urir, datetime)
# resolved to a 404, flask Response object returned instead of tuple
if isinstance(resolvedMemento, Response):
return resolvedMemento
(newDatetime, linkHeader, uri) = resolvedMemento
if newDatetime != datetime:
resp = redirect('/memento/{0}/{1}'.format(newDatetime, urir), code=302)
else:
resp = show_uri(uri, newDatetime)
resp.headers['Link'] = linkHeader