Skip to content

Commit

Permalink
Tests: ensure revision is set prior to test runs
Browse files Browse the repository at this point in the history
Newer fakeredis versions flush their internal state after every test run
to keep them isolated. This means we need to reinitialize the revision
counter for some of our tests.
  • Loading branch information
julen committed Jan 8, 2020
1 parent 3821bfd commit 923920e
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 14 deletions.
12 changes: 0 additions & 12 deletions tests/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,14 @@ def setup(self, request):
"""
data_file = self.data_file
if os.path.isfile(data_file):
from pootle_store.models import Unit

self.setup_case_sensitive_schema()
call_command('loaddata', data_file)
self.setup_redis(revision=Unit.max_revision())
else:
self.setup_site_db(request)
with open(data_file, 'w') as file:
call_command('dumpdata', '--indent=3', stdout=file)

def setup_site_db(self, request, **kwargs):
self.setup_redis()
self.setup_case_sensitive_schema()
self.setup_site_root()
self.setup_languages()
Expand Down Expand Up @@ -179,14 +175,6 @@ def setup_languages(self):
from .fixtures.models.language import _require_language
_require_language('en', 'English')

def setup_redis(self, revision=None):
from pootle.core.models import Revision

if revision is None:
Revision.initialize(force=True)
else:
Revision.set(revision)

def setup_system_users(self, request):
from .fixtures.models.user import TEST_USERS, _require_user

Expand Down
2 changes: 1 addition & 1 deletion tests/models/store.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@


@pytest.mark.django_db
def test_delete_mark_obsolete(project0_disk, store0):
def test_delete_mark_obsolete(project0_disk, store0, revision):
"""Tests that the in-DB Store and Directory are marked as obsolete
after the on-disk file ceased to exist.
Expand Down
2 changes: 1 addition & 1 deletion tests/views/timeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ def test_timeline_view_unit_disabled_project(client, request_users,

@pytest.mark.django_db
def test_timeline_view_unit_with_suggestion(client, request_users,
system, admin, store0):
system, admin, store0, revision):
# test with "state change" subission - apparently this is what is required
# to get one
suggestion = Suggestion.objects.filter(
Expand Down

0 comments on commit 923920e

Please sign in to comment.