Flagsmith/flagsmith

`test_cannot_create_superuser_if_any_user_exists` is flaky

Open

#6 841 ouverte le 4 mars 2026

Voir sur GitHub
 (0 commentaires) (0 réactions) (0 assignés)Python (264 forks)batch import
apigood first issue

Métriques du dépôt

Stars
 (3 475 stars)
Métriques de merge PR
 (Merge moyen 3j 7h) (157 PRs mergées en 30 j)

Description

=================================== FAILURES ===================================
_______________ test_cannot_create_superuser_if_any_user_exists ________________
[gw0] linux -- Python 3.11.14 /home/runner/.cache/pypoetry/virtualenvs/flagsmith-api-h9Rv37Cj-py3.11/bin/python

admin_user = <FFAdminUser: admin@example.com>
api_client = <rest_framework.test.APIClient object at 0x7f6ac9dc2850>
mocker = <pytest_mock.plugin.MockerFixture object at 0x7f6ac9dc3350>

    def test_cannot_create_superuser_if_any_user_exists(
        admin_user: FFAdminUser, api_client: APIClient, mocker: MockerFixture
    ) -> None:
        # Given
        mocker.patch("custom_auth.serializers.is_saas", return_value=False)
    
        email = "test@example.com"
        password = FFAdminUser.objects.make_random_password()
        register_data = {
            "email": email,
            "password": password,
            "re_password": password,
            "first_name": "user",
            "last_name": "test",
            "superuser": True,
        }
        url = reverse("api-v1:custom_auth:ffadminuser-list")
    
        # When
        response = api_client.post(url, data=register_data)
    
        # Then
        assert response.status_code == status.HTTP_400_BAD_REQUEST
>       assert response.json()["superuser"] == [
            "A superuser can only be created through this  endpoint if no other users exist."
        ]
E       KeyError: 'superuser'

Guide contributeur