Skip to content
Snippets Groups Projects
Verified Commit 2f3343fa authored by Nik | Klampfradler's avatar Nik | Klampfradler
Browse files

Serialise rollbacks in tests and make data migrations deterministic

parent 998cd52b
No related branches found
No related tags found
No related merge requests found
# Generated by Django 2.2.8 on 2019-12-11 23:27
from django.db import migrations, models
def mark_current_term(apps, schema_editor):
db_alias = schema_editor.connection.alias
SchoolTerm = apps.get_model('core', 'SchoolTerm') # noqa
if not SchoolTerm.objects.filter(current=True).exists():
SchoolTerm.objects.using(db_alias).latest('date_start').update(current=True)
class Migration(migrations.Migration):
dependencies = [
('core', '0006_create_superuser'),
]
operations = [
migrations.RemoveField(
model_name='school',
name='current_term',
),
migrations.AddField(
model_name='schoolterm',
name='current',
field=models.NullBooleanField(default=None, unique=True),
),
]
......@@ -38,7 +38,9 @@ class School(models.Model):
logo = ImageCropField(verbose_name=_('School logo'), blank=True, null=True)
logo_cropping = ImageRatioField('logo', '600x600', size_warning=True)
current_term = models.ForeignKey('SchoolTerm', models.CASCADE, related_name='+')
@property
def current_term(self):
return SchoolTerm.objects.get(current=True)
class Meta:
ordering = ['name', 'name_official']
......@@ -57,6 +59,13 @@ class SchoolTerm(models.Model):
date_end = models.DateField(verbose_name=_(
'Effective end date of term'), null=True)
current = models.NullBooleanField(default=None, unique=True)
def save(self, *args, **kwargs):
if self.current is False:
self.current = None
super().save(*args, **kwargs)
class Person(models.Model, ExtensibleModel):
""" A model describing any person related to a school, including, but not
......
......@@ -11,6 +11,8 @@ SeleniumTestCaseBase.browsers = list(filter(bool, os.environ.get('TEST_SELENIUM_
SeleniumTestCaseBase.selenium_hub = os.environ.get('TEST_SELENIUM_HUB', '') or None
class SeleniumTests(SeleniumTestCase):
serialized_rollback = True
@classmethod
def _screenshot(cls, filename):
screenshot_path = os.environ.get('TEST_SCREENSHOT_PATH', None)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment