TST: 100% coverage

This commit is contained in:
Matthew Ryan Dillon 2016-08-21 18:47:16 -07:00
parent 02a21306fe
commit 8622e2323d
8 changed files with 166 additions and 79 deletions

View 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)

View file

@ -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))