def test_refill_create_activates_by_default(self): refill = RefillCreator( self.subject_identifier, refill_date=get_utcnow().date(), number_of_days=32, dosage_guideline=self.dosage_guideline, formulation=self.formulation, ) self.assertTrue(refill.object.active)
def test_refill_gets_rx(self): refill_creator = RefillCreator( self.subject_identifier, refill_date=get_utcnow(), number_of_days=32, dosage_guideline=self.dosage_guideline, formulation=self.formulation, ) self.assertTrue(refill_creator.rx)
def test_refill_create_does_not_activate_if_false(self): refill = RefillCreator( self.subject_identifier, refill_date=get_utcnow().date(), number_of_days=32, dosage_guideline=self.dosage_guideline, formulation=self.formulation, make_active=False, ) self.assertFalse(refill.object.active)
def test_refill_create_and_no_active_refill(self): refill_creator = RefillCreator( self.subject_identifier, refill_date=get_utcnow(), number_of_days=32, dosage_guideline=self.dosage_guideline, formulation=self.formulation, make_active=False, ) self.assertIsNone(refill_creator.active_refill)
def test_refill_create_refill_date(self): refill_date = get_utcnow().date() refill_creator = RefillCreator( self.subject_identifier, refill_date=refill_date, number_of_days=32, dosage_guideline=self.dosage_guideline, formulation=self.formulation, ) self.assertEqual(refill_creator.object.refill_date, refill_date)
def test_refill_create_and_gets_active_refill(self): refill_creator = RefillCreator( self.subject_identifier, refill_date=get_utcnow(), number_of_days=32, dosage_guideline=self.dosage_guideline, formulation=self.formulation, ) self.assertTrue(refill_creator.active_refill) self.assertTrue(refill_creator.active_refill.active) self.assertEqual(refill_creator.object, refill_creator.active_refill)
def test_refill_create_activates_next(self): refill_creator1 = RefillCreator( self.subject_identifier, refill_date=get_utcnow(), number_of_days=32, dosage_guideline=self.dosage_guideline, formulation=self.formulation, ) refill_creator2 = RefillCreator( self.subject_identifier, refill_date=get_utcnow() + relativedelta(months=1), number_of_days=32, dosage_guideline=self.dosage_guideline, formulation=self.formulation, make_active=True, ) refill_creator1.object.refresh_from_db() self.assertFalse(refill_creator1.object.active) self.assertTrue(refill_creator2.object.active) refill_creator1.object.active = True self.assertRaises(ActivePrescriptionRefillExists, refill_creator1.object.save)
def test_refill_create_finds_active(self): refill_creator = RefillCreator( self.subject_identifier, refill_date=get_utcnow(), number_of_days=32, dosage_guideline=self.dosage_guideline, formulation=self.formulation, make_active=True, ) self.assertIsNotNone(refill_creator.active_refill) refill_creator.object.active = False refill_creator.object.save() refill_creator.object.refresh_from_db() self.assertIsNone(refill_creator.active_refill)
def test_refill_create_duplicate_raises(self): RefillCreator( self.subject_identifier, refill_date=get_utcnow(), number_of_days=32, dosage_guideline=self.dosage_guideline, formulation=self.formulation, ) self.assertRaises( PrescriptionRefillError, RefillCreator, self.subject_identifier, refill_date=get_utcnow(), number_of_days=32, dosage_guideline=self.dosage_guideline, formulation=self.formulation, )