add collection-species to data import and tests
This commit is contained in:
parent
1b5cf2ebea
commit
067448943e
3 changed files with 73 additions and 5 deletions
|
@ -1,8 +1,8 @@
|
|||
from django.test import TestCase
|
||||
from django.db import IntegrityError, transaction
|
||||
|
||||
from ..models import Species
|
||||
from ..factories import SpeciesFactory
|
||||
from ..models import Species, CollectionSpecies
|
||||
from ..factories import SpeciesFactory, CollectionSpeciesFactory
|
||||
|
||||
|
||||
class SpeciesTestCase(TestCase):
|
||||
|
@ -17,3 +17,18 @@ class SpeciesTestCase(TestCase):
|
|||
SpeciesFactory(common_name=s1.common_name, species=s1.species)
|
||||
s3 = SpeciesFactory()
|
||||
self.assertTrue(isinstance(s3, Species))
|
||||
|
||||
|
||||
class CollectionSpeciesTestCase(TestCase):
|
||||
def test_creation(self):
|
||||
c = CollectionSpeciesFactory()
|
||||
self.assertTrue(isinstance(c, CollectionSpecies))
|
||||
label = "{} {}".format(c.collection, c.species)
|
||||
self.assertEqual(c.__str__(), label)
|
||||
|
||||
def test_uniqueness(self):
|
||||
c1 = CollectionSpeciesFactory()
|
||||
with transaction.atomic(), self.assertRaises(IntegrityError):
|
||||
CollectionSpeciesFactory(collection=c1.collection, species=c1.species)
|
||||
c3 = CollectionSpeciesFactory()
|
||||
self.assertTrue(isinstance(c3, CollectionSpecies))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue