mirror of
https://gitlab.com/animath/si/plateforme-corres2math.git
synced 2025-07-04 19:44:05 +02:00
Personal page
This commit is contained in:
@ -23,6 +23,11 @@ class TestRegistration(TestCase):
|
||||
)
|
||||
self.client.force_login(self.user)
|
||||
|
||||
self.student = User.objects.create(email="student@example.com")
|
||||
StudentRegistration.objects.create(user=self.student, student_class=11, school="Earth")
|
||||
self.coach = User.objects.create(email="coach@example.com")
|
||||
CoachRegistration.objects.create(user=self.coach, professional_activity="Teacher")
|
||||
|
||||
def test_registration(self):
|
||||
response = self.client.get(reverse("registration:signup"))
|
||||
self.assertEqual(response.status_code, 200)
|
||||
@ -105,15 +110,46 @@ class TestRegistration(TestCase):
|
||||
))
|
||||
self.assertRedirects(response, reverse("index"), 302, 200)
|
||||
|
||||
def test_change_email(self):
|
||||
self.user.email = "newaddressmail@example.com"
|
||||
self.user.save()
|
||||
self.assertEqual(self.user.email, self.user.username)
|
||||
def test_user_detail(self):
|
||||
response = self.client.get(reverse("registration:my_account_detail"))
|
||||
self.assertRedirects(response, reverse("registration:user_detail", args=(self.user.pk,)))
|
||||
|
||||
response = self.client.get(reverse("registration:user_detail", args=(self.user.pk,)))
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
def test_update_user(self):
|
||||
for user, data in [(self.user, dict(role="Bot")),
|
||||
(self.student, dict(student_class=11, school="Sky")),
|
||||
(self.coach, dict(professional_activity="God"))]:
|
||||
response = self.client.get(reverse("registration:update_user", args=(user.pk,)))
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
response = self.client.post(reverse("registration:update_user", args=(user.pk,)), data=dict(
|
||||
first_name="Changed",
|
||||
last_name="Name",
|
||||
email="new_" + user.email,
|
||||
give_contact_to_animath=True,
|
||||
))
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
data.update(
|
||||
first_name="Changed",
|
||||
last_name="Name",
|
||||
email="new_" + user.email,
|
||||
give_contact_to_animath=True,
|
||||
)
|
||||
response = self.client.post(reverse("registration:update_user", args=(user.pk,)), data=data)
|
||||
self.assertRedirects(response, reverse("registration:user_detail", args=(user.pk,)), 302, 200)
|
||||
user.refresh_from_db()
|
||||
self.assertEqual(user.email, user.username)
|
||||
self.assertFalse(user.registration.email_confirmed)
|
||||
self.assertEqual(user.first_name, "Changed")
|
||||
|
||||
def test_string_render(self):
|
||||
# TODO These string field tests will be removed when used in a template
|
||||
str(self.user.registration)
|
||||
self.assertRaises(NotImplementedError, lambda: Registration().type)
|
||||
self.assertRaises(NotImplementedError, lambda: Registration().form_class)
|
||||
str(StudentRegistration().type)
|
||||
str(CoachRegistration().type)
|
||||
str(self.user.registration.type) # AdminRegistration
|
||||
|
Reference in New Issue
Block a user