aboutsummaryrefslogtreecommitdiffstats
path: root/mediagoblin/tests/test_ldap.py
diff options
context:
space:
mode:
authorBen Sturmfels <ben@sturm.com.au>2021-03-05 23:12:19 +1100
committerBen Sturmfels <ben@sturm.com.au>2021-03-05 23:12:19 +1100
commitdec47c7102cf0aa3a4debf002928db8e460c0d71 (patch)
tree47631fc15c7af172aa699506adf3d76d3a71976c /mediagoblin/tests/test_ldap.py
parent5f3a782fef4855e10b7259624a14d8afb0f7be93 (diff)
downloadmediagoblin-dec47c7102cf0aa3a4debf002928db8e460c0d71.tar.lz
mediagoblin-dec47c7102cf0aa3a4debf002928db8e460c0d71.tar.xz
mediagoblin-dec47c7102cf0aa3a4debf002928db8e460c0d71.zip
Apply `pyupgrade --py3-plus` to remove Python 2 compatibility code.
Diffstat (limited to 'mediagoblin/tests/test_ldap.py')
-rw-r--r--mediagoblin/tests/test_ldap.py36
1 files changed, 18 insertions, 18 deletions
diff --git a/mediagoblin/tests/test_ldap.py b/mediagoblin/tests/test_ldap.py
index 6ac0fc46..0af1b7f5 100644
--- a/mediagoblin/tests/test_ldap.py
+++ b/mediagoblin/tests/test_ldap.py
@@ -18,7 +18,7 @@ import pkg_resources
import pytest
import six
try:
- import mock
+ from unittest import mock
except ImportError:
import unittest.mock as mock
@@ -43,7 +43,7 @@ def ldap_plugin_app(request):
def return_value():
- return u'chris', u'chris@example.com'
+ return 'chris', 'chris@example.com'
def test_ldap_plugin(ldap_plugin_app):
@@ -65,8 +65,8 @@ def test_ldap_plugin(ldap_plugin_app):
context = template.TEMPLATE_TEST_CONTEXT['mediagoblin/auth/login.html']
form = context['login_form']
- assert form.username.errors == [u'This field is required.']
- assert form.password.errors == [u'This field is required.']
+ assert form.username.errors == ['This field is required.']
+ assert form.password.errors == ['This field is required.']
@mock.patch('mediagoblin.plugins.ldap.tools.LDAP.login',
mock.Mock(return_value=return_value()))
@@ -74,21 +74,21 @@ def test_ldap_plugin(ldap_plugin_app):
template.clear_test_template_context()
res = ldap_plugin_app.post(
'/auth/ldap/login/',
- {'username': u'chris',
- 'password': u'toast'})
+ {'username': 'chris',
+ 'password': 'toast'})
context = template.TEMPLATE_TEST_CONTEXT[
'mediagoblin/auth/register.html']
register_form = context['register_form']
- assert register_form.username.data == u'chris'
- assert register_form.email.data == u'chris@example.com'
+ assert register_form.username.data == 'chris'
+ assert register_form.email.data == 'chris@example.com'
template.clear_test_template_context()
res = ldap_plugin_app.post(
'/auth/ldap/register/',
- {'username': u'chris',
- 'email': u'chris@example.com'})
+ {'username': 'chris',
+ 'email': 'chris@example.com'})
res.follow()
assert urlparse.urlsplit(res.location)[2] == '/u/chris/'
@@ -99,24 +99,24 @@ def test_ldap_plugin(ldap_plugin_app):
template.clear_test_template_context()
res = ldap_plugin_app.post(
'/auth/ldap/register/',
- {'username': u'chris',
- 'email': u'chris@example.com'})
+ {'username': 'chris',
+ 'email': 'chris@example.com'})
context = template.TEMPLATE_TEST_CONTEXT[
'mediagoblin/auth/register.html']
register_form = context['register_form']
assert register_form.email.errors == [
- u'Sorry, a user with that email address already exists.']
+ 'Sorry, a user with that email address already exists.']
assert register_form.username.errors == [
- u'Sorry, a user with that name already exists.']
+ 'Sorry, a user with that name already exists.']
# Log out
ldap_plugin_app.get('/auth/logout/')
# Get user and detach from session
test_user = mg_globals.database.LocalUser.query.filter(
- LocalUser.username==u'chris'
+ LocalUser.username=='chris'
).first()
Session.expunge(test_user)
@@ -124,8 +124,8 @@ def test_ldap_plugin(ldap_plugin_app):
template.clear_test_template_context()
res = ldap_plugin_app.post(
'/auth/ldap/login/',
- {'username': u'chris',
- 'password': u'toast'})
+ {'username': 'chris',
+ 'password': 'toast'})
res.follow()
assert urlparse.urlsplit(res.location)[2] == '/'
@@ -134,6 +134,6 @@ def test_ldap_plugin(ldap_plugin_app):
# Make sure user is in the session
context = template.TEMPLATE_TEST_CONTEXT['mediagoblin/root.html']
session = context['request'].session
- assert session['user_id'] == six.text_type(test_user.id)
+ assert session['user_id'] == str(test_user.id)
_test_authentication()