Skip to content

Commit

Permalink
Simplify test code
Browse files Browse the repository at this point in the history
Co-authored-by: Mike VanDenburgh <37340715+mvandenburgh@users.noreply.github.com>
  • Loading branch information
waxlamp and mvandenburgh committed Sep 20, 2024
1 parent f42558a commit a8b5bd6
Showing 1 changed file with 2 additions and 22 deletions.
24 changes: 2 additions & 22 deletions dandiapi/api/tests/test_stats.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from __future__ import annotations

from django.contrib.auth.models import User
import pytest

from dandiapi.api.models import UserMetadata
Expand Down Expand Up @@ -35,30 +34,11 @@ def test_stats_published(api_client, published_version_factory):

@pytest.mark.django_db
def test_stats_user(api_client, user_factory):

# Create multiple users with different statuses
approved_user_count = 0
users_per_status = 3
user_index = 0
users_per_status = approved_user_count = 3

for status in UserMetadata.Status.choices:
status_value = status[0]
for _ in range(users_per_status):
username = f'{status_value.lower()}_user_{user_index}'
user = user_factory(username=username)
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
[user_factory(metadata__status=status[0]) for _ in range(users_per_status)]

stats = api_client.get('/api/stats/').data

Expand Down

0 comments on commit a8b5bd6

Please sign in to comment.