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_form(self):
"""
test custom login form
:return:
"""
initial = {'username': user_username, 'password': user_pass}
form = BigAuthenticationForm(data=initial)
assert form.is_valid()
assert form.cleaned_data['username'] == user_username
assert form.cleaned_data['password'] == user_pass
# Longer than contrib.auth default of 30 chars
new_uname = '{} as {}'.format(admin_username, user_username)
initial = {'username': new_uname, 'password': admin_pass}
form = BigAuthenticationForm(data=initial)
assert form.is_valid()
assert form.cleaned_data['username'] == new_uname
assert form.cleaned_data['password'] == admin_pass
del initial['password']
form = BigAuthenticationForm(data=initial)
assert not form.is_valid()
initial = {'username': user_username, 'password': user_pass}
form = BigAuthenticationForm(data=initial)
assert form.is_valid()
assert form.cleaned_data['username'] == user_username
assert form.cleaned_data['password'] == user_pass
# Longer than contrib.auth default of 30 chars
new_uname = '{} as {}'.format(admin_username, user_username)
initial = {'username': new_uname, 'password': admin_pass}
form = BigAuthenticationForm(data=initial)
assert form.is_valid()
assert form.cleaned_data['username'] == new_uname
assert form.cleaned_data['password'] == admin_pass
del initial['password']
form = BigAuthenticationForm(data=initial)
assert not form.is_valid()