processing: tests and data migration
This commit is contained in:
parent
afa22b046b
commit
033568646f
5 changed files with 169 additions and 2 deletions
0
ccdb/processing/tests/__init__.py
Normal file
0
ccdb/processing/tests/__init__.py
Normal file
58
ccdb/processing/tests/test_models.py
Normal file
58
ccdb/processing/tests/test_models.py
Normal file
|
@ -0,0 +1,58 @@
|
|||
from django.test import TestCase
|
||||
from django.db import IntegrityError, transaction
|
||||
|
||||
from ..models import ProcessType, Reagent, Flaw, Processing
|
||||
from ..factories import ProcessTypeFactory, ReagentFactory, FlawFactory, ProcessingFactory
|
||||
|
||||
|
||||
class ProcessTypeTestCase(TestCase):
|
||||
def test_creation(self):
|
||||
p = ProcessTypeFactory()
|
||||
self.assertTrue(isinstance(p, ProcessType))
|
||||
self.assertEqual(p.__str__(), p.name)
|
||||
|
||||
def test_uniqueness(self):
|
||||
p1 = ProcessTypeFactory()
|
||||
with transaction.atomic(), self.assertRaises(IntegrityError):
|
||||
ProcessTypeFactory(name=p1.name, code=p1.code)
|
||||
p3 = ProcessTypeFactory()
|
||||
self.assertTrue(isinstance(p3, ProcessType))
|
||||
|
||||
|
||||
class ReagentTestCase(TestCase):
|
||||
def test_creation(self):
|
||||
r = ReagentFactory()
|
||||
self.assertTrue(isinstance(r, Reagent))
|
||||
self.assertEqual(r.__str__(), r.name)
|
||||
|
||||
def test_uniqueness(self):
|
||||
r1 = ReagentFactory()
|
||||
with transaction.atomic(), self.assertRaises(IntegrityError):
|
||||
ReagentFactory(name=r1.name, code=r1.code)
|
||||
r3 = ReagentFactory()
|
||||
self.assertTrue(isinstance(r3, Reagent))
|
||||
|
||||
|
||||
class FlawTestCase(TestCase):
|
||||
def test_creation(self):
|
||||
f = FlawFactory()
|
||||
self.assertTrue(isinstance(f, Flaw))
|
||||
self.assertEqual(f.__str__(), f.name)
|
||||
|
||||
|
||||
class ProcessingTestCase(TestCase):
|
||||
def test_creation(self):
|
||||
p = ProcessingFactory()
|
||||
self.assertTrue(isinstance(p, Processing))
|
||||
name = "{} {} {}".format(p.process_date, p.process_type, p.container_label)
|
||||
self.assertEqual(p.__str__(), name)
|
||||
|
||||
def test_uniqueness(self):
|
||||
p1 = ProcessingFactory()
|
||||
with transaction.atomic(), self.assertRaises(IntegrityError):
|
||||
ProcessingFactory(process_type=p1.process_type, container=p1.container,
|
||||
container_label=p1.container_label,
|
||||
process_date=p1.process_date,
|
||||
process_time=p1.process_time, reagent=p1.reagent)
|
||||
p3 = ProcessingFactory()
|
||||
self.assertTrue(isinstance(p3, Processing))
|
Loading…
Add table
Add a link
Reference in a new issue