From ee11e9e44f56be605d79ac97c4b106b70d17760c Mon Sep 17 00:00:00 2001 From: Aaron Kanzer Date: Mon, 16 Sep 2024 13:39:58 -0400 Subject: [PATCH] Resolve UserMetadata issue --- dandiapi/api/tests/test_stats.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/dandiapi/api/tests/test_stats.py b/dandiapi/api/tests/test_stats.py index 2d11d8fd9..946f95102 100644 --- a/dandiapi/api/tests/test_stats.py +++ b/dandiapi/api/tests/test_stats.py @@ -47,7 +47,16 @@ def test_stats_user(api_client, user_factory): for _ in range(users_per_status): username = f'{status_value.lower()}_user_{user_index}' user = user_factory(username=username) - UserMetadata.objects.create(user=user, status=status_value) + user_metadata, created = UserMetadata.objects.get_or_create( + user=user, + defaults={ + 'status': status_value, + 'questionnaire_form': None, + 'rejection_reason': '' + } + ) + if not created: + pass if status_value == UserMetadata.Status.APPROVED: approved_user_count += 1 user_index += 1