Skip to content

Commit

Permalink
Merge pull request #1572 from dandi/fix-flaky-version-test
Browse files Browse the repository at this point in the history
  • Loading branch information
danlamanna authored Apr 11, 2023
2 parents e042f79 + 79b93db commit 185a583
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
8 changes: 6 additions & 2 deletions dandiapi/api/tests/test_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

from django.conf import settings
from django.contrib.auth.models import User
from freezegun import freeze_time
from guardian.shortcuts import assign_perm
import pytest

Expand Down Expand Up @@ -48,8 +49,11 @@ def test_version_next_published_version_simultaneous_save(
):
dandiset_1 = dandiset_factory()
dandiset_2 = dandiset_factory()
version_1 = published_version_factory(dandiset=dandiset_1)
version_2 = published_version_factory(dandiset=dandiset_2)
with freeze_time():
# version strings have a time component. mock all functions that retrieve the
# current time so the test isn't flaky at time boundaries.
version_1 = published_version_factory(dandiset=dandiset_1)
version_2 = published_version_factory(dandiset=dandiset_2)
# Different dandisets published at the same time should have the same version string
assert version_1.version == version_2.version

Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
],
'test': [
'factory-boy',
'freezegun',
'pytest',
'pytest-cov',
'pytest-django',
Expand Down

0 comments on commit 185a583

Please sign in to comment.