Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix flaky version string test #1572

Merged
merged 1 commit into from
Apr 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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