mirror of
https://git.linux-kernel.at/oliver/ivatar.git
synced 2025-11-15 20:48:02 +00:00
Fix a few tests to work properly again
This commit is contained in:
@@ -456,11 +456,18 @@ class Tester(TestCase): # pylint: disable=too-many-public-methods
|
|||||||
},
|
},
|
||||||
follow=True,
|
follow=True,
|
||||||
) # Create test addresses + 1 too much
|
) # Create test addresses + 1 too much
|
||||||
# TODO: This test isn't super criticial, but needs to be fixed
|
# Check the response context for form errors
|
||||||
# Currently issues an error with an unbound form
|
self.assertTrue(
|
||||||
# self.assertFormError(
|
hasattr(response, "context"), "Response does not have a context"
|
||||||
# response, "form", None, "Too many unconfirmed mail addresses!"
|
)
|
||||||
# )
|
form = response.context.get("form")
|
||||||
|
self.assertIsNotNone(form, "No form found in response context")
|
||||||
|
|
||||||
|
# Verify form errors
|
||||||
|
self.assertFalse(form.is_valid(), "Form should not be valid")
|
||||||
|
self.assertIn(
|
||||||
|
"Too many unconfirmed mail addresses!", form.errors.get("__all__", [])
|
||||||
|
)
|
||||||
|
|
||||||
def test_add_mail_address_twice(self):
|
def test_add_mail_address_twice(self):
|
||||||
"""
|
"""
|
||||||
@@ -479,11 +486,18 @@ class Tester(TestCase): # pylint: disable=too-many-public-methods
|
|||||||
},
|
},
|
||||||
follow=True,
|
follow=True,
|
||||||
)
|
)
|
||||||
# TODO: This test isn't super criticial, but needs to be fixed
|
# Check the response context for form errors
|
||||||
# Currently issues an error with an unbound form
|
self.assertTrue(
|
||||||
# self.assertFormError(
|
hasattr(response, "context"), "Response does not have a context"
|
||||||
# response, "form", "email", "Address already added, currently unconfirmed"
|
)
|
||||||
# )
|
form = response.context.get("form")
|
||||||
|
self.assertIsNotNone(form, "No form found in response context")
|
||||||
|
|
||||||
|
# Verify form errors
|
||||||
|
self.assertFalse(form.is_valid(), "Form should not be valid")
|
||||||
|
self.assertIn(
|
||||||
|
"Address already added, currently unconfirmed", form.errors.get("email", [])
|
||||||
|
)
|
||||||
|
|
||||||
def test_add_already_confirmed_email_self(self): # pylint: disable=invalid-name
|
def test_add_already_confirmed_email_self(self): # pylint: disable=invalid-name
|
||||||
"""
|
"""
|
||||||
@@ -500,11 +514,19 @@ class Tester(TestCase): # pylint: disable=too-many-public-methods
|
|||||||
},
|
},
|
||||||
follow=True,
|
follow=True,
|
||||||
)
|
)
|
||||||
# TODO: This test isn't super criticial, but needs to be fixed
|
|
||||||
# Currently issues an error with an unbound form
|
# Check the response context for form errors
|
||||||
# self.assertFormError(
|
self.assertTrue(
|
||||||
# response, "form", "email", "Address already confirmed (by you)"
|
hasattr(response, "context"), "Response does not have a context"
|
||||||
# )
|
)
|
||||||
|
form = response.context.get("form")
|
||||||
|
self.assertIsNotNone(form, "No form found in response context")
|
||||||
|
|
||||||
|
# Verify form errors
|
||||||
|
self.assertFalse(form.is_valid(), "Form should not be valid")
|
||||||
|
self.assertIn(
|
||||||
|
"Address already confirmed (by you)", form.errors.get("email", [])
|
||||||
|
)
|
||||||
|
|
||||||
def test_add_already_confirmed_email_other(self): # pylint: disable=invalid-name
|
def test_add_already_confirmed_email_other(self): # pylint: disable=invalid-name
|
||||||
"""
|
"""
|
||||||
@@ -528,11 +550,19 @@ class Tester(TestCase): # pylint: disable=too-many-public-methods
|
|||||||
},
|
},
|
||||||
follow=True,
|
follow=True,
|
||||||
)
|
)
|
||||||
# TODO: This test isn't super criticial, but needs to be fixed
|
|
||||||
# Currently issues an error with an unbound form
|
# Check the response context for form errors
|
||||||
# self.assertFormError(
|
self.assertTrue(
|
||||||
# response, "form", "email", "Address already confirmed (by someone)"
|
hasattr(response, "context"), "Response does not have a context"
|
||||||
# )
|
)
|
||||||
|
form = response.context.get("form")
|
||||||
|
self.assertIsNotNone(form, "No form found in response context")
|
||||||
|
|
||||||
|
# Verify form errors
|
||||||
|
self.assertFalse(form.is_valid(), "Form should not be valid")
|
||||||
|
self.assertIn(
|
||||||
|
"Address already confirmed (by someone else)", form.errors.get("email", [])
|
||||||
|
)
|
||||||
|
|
||||||
def test_remove_unconfirmed_non_existing_email(
|
def test_remove_unconfirmed_non_existing_email(
|
||||||
self,
|
self,
|
||||||
@@ -1052,11 +1082,19 @@ class Tester(TestCase): # pylint: disable=too-many-public-methods
|
|||||||
"There must only be one unconfirmed ID!",
|
"There must only be one unconfirmed ID!",
|
||||||
)
|
)
|
||||||
|
|
||||||
# TODO: This test isn't super criticial, but needs to be fixed
|
# Check the response context for form errors
|
||||||
# Currently issues an error with an unbound form
|
self.assertTrue(
|
||||||
# self.assertFormError(
|
hasattr(response, "context"), "Response does not have a context"
|
||||||
# response, "form", "openid", "OpenID already added, but not confirmed yet!"
|
)
|
||||||
# )
|
form = response.context.get("form")
|
||||||
|
self.assertIsNotNone(form, "No form found in response context")
|
||||||
|
|
||||||
|
# Verify form errors
|
||||||
|
self.assertFalse(form.is_valid(), "Form should not be valid")
|
||||||
|
self.assertIn(
|
||||||
|
"OpenID already added, but not confirmed yet!",
|
||||||
|
form.errors.get("openid", []),
|
||||||
|
)
|
||||||
|
|
||||||
# Manual confirm, since testing is _really_ hard!
|
# Manual confirm, since testing is _really_ hard!
|
||||||
unconfirmed = self.user.unconfirmedopenid_set.first()
|
unconfirmed = self.user.unconfirmedopenid_set.first()
|
||||||
@@ -1075,11 +1113,19 @@ class Tester(TestCase): # pylint: disable=too-many-public-methods
|
|||||||
},
|
},
|
||||||
follow=True,
|
follow=True,
|
||||||
)
|
)
|
||||||
# TODO: This test isn't super criticial, but needs to be fixed
|
|
||||||
# Currently issues an error with an unbound form
|
# Check the response context for form errors
|
||||||
# self.assertFormError(
|
self.assertTrue(
|
||||||
# response, "form", "openid", "OpenID already added and confirmed!"
|
hasattr(response, "context"), "Response does not have a context"
|
||||||
# )
|
)
|
||||||
|
form = response.context.get("form")
|
||||||
|
self.assertIsNotNone(form, "No form found in response context")
|
||||||
|
|
||||||
|
# Verify form errors
|
||||||
|
self.assertFalse(form.is_valid(), "Form should not be valid")
|
||||||
|
self.assertIn(
|
||||||
|
"OpenID already added and confirmed!", form.errors.get("openid", [])
|
||||||
|
)
|
||||||
|
|
||||||
def test_assign_photo_to_openid(self):
|
def test_assign_photo_to_openid(self):
|
||||||
"""
|
"""
|
||||||
@@ -1529,9 +1575,6 @@ class Tester(TestCase): # pylint: disable=too-many-public-methods
|
|||||||
"""
|
"""
|
||||||
Test fetching avatar for not existing mail with default specified
|
Test fetching avatar for not existing mail with default specified
|
||||||
"""
|
"""
|
||||||
# TODO - Find a new way
|
|
||||||
# Do not run this test, since static serving isn't allowed in testing mode
|
|
||||||
return
|
|
||||||
urlobj = urlsplit(
|
urlobj = urlsplit(
|
||||||
libravatar_url(
|
libravatar_url(
|
||||||
"xxx@xxx.xxx",
|
"xxx@xxx.xxx",
|
||||||
@@ -1553,9 +1596,6 @@ class Tester(TestCase): # pylint: disable=too-many-public-methods
|
|||||||
"""
|
"""
|
||||||
Test fetching avatar for not existing mail with default specified
|
Test fetching avatar for not existing mail with default specified
|
||||||
"""
|
"""
|
||||||
# TODO - Find a new way
|
|
||||||
# Do not run this test, since static serving isn't allowed in testing mode
|
|
||||||
return
|
|
||||||
urlobj = urlsplit(
|
urlobj = urlsplit(
|
||||||
libravatar_url(
|
libravatar_url(
|
||||||
"xxx@xxx.xxx",
|
"xxx@xxx.xxx",
|
||||||
@@ -1565,10 +1605,10 @@ class Tester(TestCase): # pylint: disable=too-many-public-methods
|
|||||||
)
|
)
|
||||||
url = "%s?%s&gravatarproxy=n" % (urlobj.path, urlobj.query)
|
url = "%s?%s&gravatarproxy=n" % (urlobj.path, urlobj.query)
|
||||||
response = self.client.get(url, follow=True)
|
response = self.client.get(url, follow=True)
|
||||||
self.assertRedirects(
|
self.assertEqual(
|
||||||
response=response,
|
response.redirect_chain[0][0],
|
||||||
expected_url="/static/img/nobody.png",
|
"/static/img/nobody.png",
|
||||||
msg_prefix="Why does this not redirect to the default img?",
|
"Doesn't redirect to static?",
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_avatar_url_default_external(self): # pylint: disable=invalid-name
|
def test_avatar_url_default_external(self): # pylint: disable=invalid-name
|
||||||
|
|||||||
Reference in New Issue
Block a user