species: tests and data migration
This commit is contained in:
parent
831e4091dc
commit
afa22b046b
4 changed files with 74 additions and 0 deletions
0
ccdb/species/tests/__init__.py
Normal file
0
ccdb/species/tests/__init__.py
Normal file
19
ccdb/species/tests/test_models.py
Normal file
19
ccdb/species/tests/test_models.py
Normal file
|
@ -0,0 +1,19 @@
|
|||
from django.test import TestCase
|
||||
from django.db import IntegrityError, transaction
|
||||
|
||||
from ..models import Species
|
||||
from ..factories import SpeciesFactory
|
||||
|
||||
|
||||
class SpeciesTestCase(TestCase):
|
||||
def test_creation(self):
|
||||
s = SpeciesFactory()
|
||||
self.assertTrue(isinstance(s, Species))
|
||||
self.assertEqual(s.__str__(), s.common_name)
|
||||
|
||||
def test_uniqueness(self):
|
||||
s1 = SpeciesFactory()
|
||||
with transaction.atomic(), self.assertRaises(IntegrityError):
|
||||
SpeciesFactory(common_name=s1.common_name, species=s1.species)
|
||||
s3 = SpeciesFactory()
|
||||
self.assertTrue(isinstance(s3, Species))
|
Loading…
Add table
Add a link
Reference in a new issue