Coverage
This commit is contained in:
parent
b6de46379d
commit
d69b03001c
@ -5,16 +5,16 @@ from django.db import models
|
||||
from documents.models import Document
|
||||
|
||||
|
||||
class Command(BaseCommand): # pragma: no cover
|
||||
class Command(BaseCommand):
|
||||
# This code is taken almost entirely from https://github.com/wagtail/wagtail/pull/11912 with all credit to the original author.
|
||||
help = "Converts UUID columns from char type to the native UUID type used in MariaDB 10.7+ and Django 5.0+."
|
||||
|
||||
def convert_field(self, model, field_name, null=False):
|
||||
if model._meta.get_field(field_name).model != model:
|
||||
if model._meta.get_field(field_name).model != model: # pragma: no cover
|
||||
# Field is inherited from a parent model
|
||||
return
|
||||
|
||||
if not model._meta.managed:
|
||||
if not model._meta.managed: # pragma: no cover
|
||||
# The migration framework skips unmanaged models, so we should too
|
||||
return
|
||||
|
||||
|
@ -3,6 +3,7 @@ import hashlib
|
||||
import os
|
||||
import shutil
|
||||
import tempfile
|
||||
from io import StringIO
|
||||
from pathlib import Path
|
||||
from unittest import mock
|
||||
|
||||
@ -238,3 +239,16 @@ class TestSanityChecker(DirectoriesMixin, TestCase):
|
||||
|
||||
self.assertEqual(len(capture.output), 2)
|
||||
self.assertIn("Checksum mismatch. Stored: abc, actual:", capture.output[1])
|
||||
|
||||
|
||||
class TestConvertMariaDBUUID(TestCase):
|
||||
@mock.patch("django.db.connection.schema_editor")
|
||||
def test_convert(self, m):
|
||||
m.alter_field.return_value = None
|
||||
|
||||
stdout = StringIO()
|
||||
call_command("convert_mariadb_uuid", stdout=stdout)
|
||||
|
||||
m.assert_called_once()
|
||||
|
||||
self.assertIn("Successfully converted", stdout.getvalue())
|
||||
|
Loading…
x
Reference in New Issue
Block a user