TST: 100% coverage
This commit is contained in:
parent
02a21306fe
commit
8622e2323d
8 changed files with 166 additions and 79 deletions
26
ccdb/experiments/tests/test_admin.py
Normal file
26
ccdb/experiments/tests/test_admin.py
Normal file
|
@ -0,0 +1,26 @@
|
|||
from django.test import TestCase
|
||||
from django.contrib.admin.sites import AdminSite
|
||||
|
||||
from ..models import AliveDeadCount
|
||||
from ..admin import AliveDeadCountAdmin
|
||||
from .factories import AliveDeadCountFactory
|
||||
|
||||
|
||||
class AliveDeadCountAdminTests(TestCase):
|
||||
def setUp(self):
|
||||
self.ad_count = AliveDeadCountFactory()
|
||||
self.site = AdminSite()
|
||||
|
||||
def test_list_display(self):
|
||||
admin_obj = AliveDeadCountAdmin(AliveDeadCount, self.site)
|
||||
self.assertEqual(admin_obj.check(), [])
|
||||
|
||||
treatment_from_callable = admin_obj.treatment(self.ad_count)
|
||||
self.assertEqual(treatment_from_callable,
|
||||
self.ad_count.treatment_replicate.treatment)
|
||||
|
||||
tr_from_callable = admin_obj.tr(self.ad_count)
|
||||
_tr = self.ad_count.treatment_replicate
|
||||
tr_from_related = '_'.join([str(_tr.setup_date), _tr.name,
|
||||
str(_tr.setup_sample_size)])
|
||||
self.assertEqual(tr_from_callable, tr_from_related)
|
|
@ -71,9 +71,10 @@ class TreatmentTestCase(TestCase):
|
|||
def test_uniqueness(self):
|
||||
t1 = TreatmentFactory()
|
||||
with transaction.atomic(), self.assertRaises(IntegrityError):
|
||||
TreatmentFactory(treatment_type=t1.treatment_type, container=t1.container,
|
||||
study_location=t1.study_location, species=t1.species,
|
||||
sex=t1.sex)
|
||||
TreatmentFactory(treatment_type=t1.treatment_type,
|
||||
container=t1.container,
|
||||
study_location=t1.study_location,
|
||||
species=t1.species, sex=t1.sex)
|
||||
t3 = TreatmentFactory()
|
||||
self.assertTrue(isinstance(t3, Treatment))
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue