Clean up unique on existing models
This commit is contained in:
parent
a44ac2fa81
commit
49eacdeef4
16 changed files with 141 additions and 12 deletions
|
@ -11,7 +11,7 @@ class Migration(migrations.Migration):
|
|||
name='Flaw',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, verbose_name='ID', serialize=False, primary_key=True)),
|
||||
('name', models.CharField(max_length=200)),
|
||||
('name', models.CharField(max_length=200, unique=True)),
|
||||
('description', models.CharField(max_length=255, blank=True)),
|
||||
('sort_order', models.IntegerField(null=True, blank=True)),
|
||||
],
|
||||
|
|
|
@ -30,7 +30,7 @@ class Reagent(models.Model):
|
|||
|
||||
|
||||
class Flaw(models.Model):
|
||||
name = models.CharField(max_length=200)
|
||||
name = models.CharField(max_length=200, unique=True)
|
||||
description = models.CharField(max_length=255, blank=True)
|
||||
sort_order = models.IntegerField(blank=True, null=True)
|
||||
|
||||
|
|
|
@ -39,6 +39,13 @@ class FlawTestCase(TestCase):
|
|||
self.assertTrue(isinstance(f, Flaw))
|
||||
self.assertEqual(f.__str__(), f.name)
|
||||
|
||||
def test_uniqueness(self):
|
||||
f1 = FlawFactory()
|
||||
with transaction.atomic(), self.assertRaises(IntegrityError):
|
||||
FlawFactory(name=f1.name)
|
||||
f3 = FlawFactory()
|
||||
self.assertTrue(isinstance(f3, Flaw))
|
||||
|
||||
|
||||
class ProcessingTestCase(TestCase):
|
||||
def test_creation(self):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue