Skip to content

Commit 10b3019

Browse files
committed
Removed tests that have served their purpose and are causing problems
1 parent 6c76551 commit 10b3019

2 files changed

Lines changed: 0 additions & 142 deletions

File tree

tests/testapp/tests/helpers.py

Lines changed: 0 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@
77
import factory
88
import mock
99
from django.core.serializers.json import DjangoJSONEncoder
10-
from django.db import connection
11-
from django.db.migrations.executor import MigrationExecutor
12-
from django.db.migrations.recorder import MigrationRecorder
1310
from django.test.testcases import LiveServerTestCase
1411
from django.utils import timezone
1512
from facility_profile.models import Facility
@@ -442,64 +439,3 @@ def stage_status(self):
442439
def update_state(self, stage=None, stage_status=None):
443440
self._stage = stage or self._stage
444441
self._stage_status = stage_status or self._stage_status
445-
446-
447-
class TestMigrationsMixin(object):
448-
# Modified from https://www.caktusgroup.com/blog/2016/02/02/writing-unit-tests-django-migrations/
449-
# Note that this has been updated to handle running migration tests for previously squashed migrations.
450-
# It is possible this will no longer work for testing migrations that are part of or
451-
# subsequent to a squashed migration.
452-
453-
migrate_from = None
454-
migrate_to = None
455-
app = None
456-
457-
@classmethod
458-
def setUpClass(cls):
459-
super(TestMigrationsMixin, cls).setUpClass()
460-
461-
# get the latest migration before starting
462-
latest_migration = MigrationRecorder.Migration.objects.filter(app=cls.app).last()
463-
cls.latest_migration = (cls.app, latest_migration.name)
464-
465-
def setUp(self):
466-
assert (
467-
self.migrate_from and self.migrate_to
468-
), "TestCase '{}' must define migrate_from and migrate_to properties".format(
469-
type(self).__name__
470-
)
471-
472-
migrate_from = [(self.app, self.migrate_from)]
473-
migrate_to = [(self.app, self.migrate_to)]
474-
executor = MigrationExecutor(connection)
475-
executor.migrate([(self.app, None)])
476-
executor.loader.replace_migrations = False
477-
executor.loader.build_graph() # reload.
478-
479-
old_apps = executor.loader.project_state(migrate_from).apps
480-
481-
# Reverse to the original migration
482-
executor.migrate(migrate_from)
483-
484-
self.setUpBeforeMigration(old_apps)
485-
486-
# Run the migration to test
487-
executor = MigrationExecutor(connection)
488-
executor.loader.build_graph() # reload.
489-
executor.migrate(migrate_to)
490-
491-
self.apps = executor.loader.project_state(migrate_to).apps
492-
493-
def setUpBeforeMigration(self, apps):
494-
pass
495-
496-
@classmethod
497-
def tearDownClass(cls):
498-
# revert migration back to latest migration
499-
executor = MigrationExecutor(connection)
500-
executor.migrate([(cls.app, None)])
501-
executor.loader.replace_migrations = True
502-
executor.loader.build_graph()
503-
executor.migrate([cls.latest_migration])
504-
505-
super(TestMigrationsMixin, cls).tearDownClass()

tests/testapp/tests/test_migrations.py

Lines changed: 0 additions & 78 deletions
This file was deleted.

0 commit comments

Comments
 (0)