fix(user): remove email from accounts
All checks were successful
State Corp Backend CI/CD / Quality gate (push) Successful in 2m45s
State Corp Backend CI/CD / Build linux/amd64 images once (push) Successful in 4m32s
State Corp Backend CI/CD / Release dev (push) Has been skipped
State Corp Backend CI/CD / Refresh and release internal main (push) Has been skipped
State Corp Backend CI/CD / Release customer main (push) Has been skipped

This commit is contained in:
Aleksandr Meshchryakov
2026-10-01 10:20:01 +02:00
parent 7484b3c2b6
commit 2bfbb133bc
24 changed files with 248 additions and 307 deletions

View File

@@ -25,7 +25,6 @@ class RegisterViewTest(APITestCase):
self.register_url = reverse("api_v1:user:register")
self.password = fake.password(length=12, special_chars=False)
self.user_data = {
"email": fake.unique.email(),
"username": fake.unique.user_name(),
"password": self.password,
"password_confirm": self.password,
@@ -43,7 +42,9 @@ class RegisterViewTest(APITestCase):
self.assertIn("access", response.data["tokens"])
# Verify user was created
self.assertTrue(User.objects.filter(email=self.user_data["email"]).exists())
self.assertTrue(
User.objects.filter(username=self.user_data["username"]).exists()
)
def test_register_passwords_do_not_match(self):
"""Test registration fails when passwords don't match"""
@@ -55,20 +56,6 @@ class RegisterViewTest(APITestCase):
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
self.assertIn("non_field_errors", response.data)
def test_register_duplicate_email(self):
"""Test registration fails with duplicate email"""
# Create existing user
existing_user = UserFactory.create_user()
# Use the same email as existing user
data = self.user_data.copy()
data["email"] = existing_user.email
response = self.client.post(self.register_url, data, format="json")
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
self.assertIn("email", response.data)
def test_register_short_password(self):
"""Test registration fails with short password"""
short_password = fake.pystr(min_chars=3, max_chars=5)
@@ -138,7 +125,6 @@ class CurrentUserViewTest(APITestCase):
self.assertEqual(response.status_code, status.HTTP_200_OK)
self.assertEqual(response.data["id"], self.user.id)
self.assertEqual(response.data["email"], self.user.email)
self.assertEqual(response.data["is_active"], self.user.is_active)
self.assertIn("profile", response.data)
self.assertEqual(response.data["profile"]["middle_name"], "")
@@ -283,7 +269,6 @@ class AdminUserCrudViewTest(APITestCase):
def test_admin_can_create_user_with_role_and_profile(self):
password = fake.password(length=12, special_chars=False)
payload = {
"email": fake.unique.email(),
"username": fake.unique.user_name(),
"phone": f"+7{fake.numerify('##########')}",
"password": password,
@@ -311,8 +296,7 @@ class AdminUserCrudViewTest(APITestCase):
duplicate_response = self.client.post(
self.list_url,
{
"email": self.regular_user.email,
"username": fake.unique.user_name(),
"username": self.regular_user.username,
"password": "valid-pass",
"first_name": "Иван",
"last_name": "Иванов",
@@ -322,7 +306,6 @@ class AdminUserCrudViewTest(APITestCase):
password_response = self.client.post(
self.list_url,
{
"email": fake.unique.email(),
"username": fake.unique.user_name(),
"password": "short",
"first_name": "Иван",