Skip to content

Commit

Permalink
WIP - apply Mike's pythonicization
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 authored Sep 20, 2024
1 parent f42558a commit 3a259ac
Showing 1 changed file with 8 additions and 20 deletions.
28 changes: 8 additions & 20 deletions dandiapi/api/tests/test_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,29 +36,17 @@ 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


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
users = [user_factory(username=username, metadata__status=status[0]) for _ in range(users_per_status)]

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

# Assert that the user count only includes users with APPROVED status
assert stats['user_count'] == approved_user_count

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

Expand Down

0 comments on commit 3a259ac

Please sign in to comment.