def test_panel2(self): wb = AliquotType(name="Whole Blood", alpha_code="WB", numeric_code="02") whole_blood_processing = ProcessingProfile(name="whole_blood_store", aliquot_type=wb) wb_panel = RequisitionPanel( name="wb_storage", verbose_name="Whole Blood Storage", processing_profile=whole_blood_processing, ) lab_profile = LabProfile( name="test_profile", requisition_model="edc_lab.subjectrequisition" ) lab_profile.add_panel(wb_panel) site_labs.register(lab_profile=lab_profile) try: Panel.objects.get(name="wb_storage") except ObjectDoesNotExist: self.fail("Panel unexpectedly does not exist") panel = Panel.objects.get(name="wb_storage") self.assertEqual(panel.display_name, "Whole Blood Storage") self.assertEqual(panel.lab_profile_name, "test_profile")
def setup_site_labs(self): """Sets up the site_lab global.""" site_labs._registry = {} site_labs.loaded = False self.profile_aliquot_count = 3 # create aliquots and their relationship a = AliquotType(name="aliquot_a", numeric_code="55", alpha_code="AA") b = AliquotType(name="aliquot_b", numeric_code="66", alpha_code="BB") a.add_derivatives(b) # set up processes process = Process(aliquot_type=b, aliquot_count=self.profile_aliquot_count) processing_profile = ProcessingProfile(name="process", aliquot_type=a) processing_profile.add_processes(process) # create a panel self.panel = RequisitionPanel(name="panel", processing_profile=processing_profile) # lab profile self.lab_profile = LabProfile(name="lab_profile", requisition_model=self.requisition_model) self.lab_profile.add_panel(self.panel) # register with site site_labs.register(lab_profile=self.lab_profile)
def test_added_panel_group_knows_requisition_model(self): """Assert same panel cannot be added twice.""" panel_group = self.get_panel_group() lab_profile = LabProfile( name="profile", requisition_model="edc_lab.subjectrequisition") lab_profile.add_panel(panel_group) panel = lab_profile.panels.get(panel_group.name) self.assertEqual(panel.requisition_model, "edc_lab.subjectrequisition") self.assertEqual(panel.requisition_model_cls, SubjectRequisition)
def test_add_processing(self): a = AliquotType(name="aliquot_a", numeric_code="55", alpha_code="AA") b = AliquotType(name="aliquot_b", numeric_code="66", alpha_code="BB") a.add_derivatives(b) process = Process(aliquot_type=b, aliquot_count=3) processing_profile = ProcessingProfile(name="process", aliquot_type=a) processing_profile.add_processes(process) panel = RequisitionPanel(name="Viral Load", processing_profile=processing_profile) lab_profile = LabProfile( name="profile", requisition_model="edc_lab.subjectrequisition") lab_profile.add_panel(panel)
def test_add_panel_group(self): panel_group = self.get_panel_group() lab_profile = LabProfile( name="profile", requisition_model="edc_lab.subjectrequisition", ) lab_profile.add_panel(panel_group) panel = lab_profile.panels.get(panel_group.name) self.assertIsNotNone(panel) self.assertEqual(len(panel.utest_ids), 13) self.assertRaises(PanelAlreadyRegistered, lab_profile.add_panel, panel_group)
def test_panel_adds_processing_profile(self): a = AliquotType(name="aliquot_a", numeric_code="55", alpha_code="AA") b = AliquotType(name="aliquot_b", numeric_code="66", alpha_code="BB") a.add_derivatives(b) process = Process(aliquot_type=b, aliquot_count=3) processing_profile = ProcessingProfile(name="process", aliquot_type=a) processing_profile.add_processes(process) panel = RequisitionPanel(name="some panel", processing_profile=processing_profile) lab_profile = LabProfile( name="profile", requisition_model="edc_lab.subjectrequisition") lab_profile.add_panel(panel) self.assertEqual(panel, lab_profile.panels.get(panel.name))
def setUp(self): self.requisition_model = "edc_lab.subjectrequisition" a = AliquotType(name="aliquot_a", numeric_code="55", alpha_code="AA") b = AliquotType(name="aliquot_b", numeric_code="66", alpha_code="BB") a.add_derivatives(b) process = Process(aliquot_type=b, aliquot_count=3) processing_profile = ProcessingProfile(name="process", aliquot_type=a) processing_profile.add_processes(process) panel = RequisitionPanel(name="Viral Load", processing_profile=processing_profile) self.lab_profile = LabProfile(name="profile", requisition_model=self.requisition_model) self.lab_profile.add_panel(panel) site_labs._registry = {} site_labs.loaded = False site_labs.register(lab_profile=self.lab_profile)
def test_add_panel(self): """Assert same panel cannot be added twice.""" a = AliquotType(name="aliquot_a", numeric_code="55", alpha_code="AA") b = AliquotType(name="aliquot_b", numeric_code="66", alpha_code="BB") a.add_derivatives(b) process = Process(aliquot_type=b, aliquot_count=3) processing_profile = ProcessingProfile(name="process", aliquot_type=a) processing_profile.add_processes(process) panel = RequisitionPanel(name="Viral Load", processing_profile=processing_profile) lab_profile = LabProfile( name="profile", requisition_model="edc_lab.subjectrequisition") lab_profile.add_panel(panel) self.assertRaises(PanelAlreadyRegistered, lab_profile.add_panel, panel)
def test_added_panel_knows_requisition_model(self): """Assert same panel cannot be added twice.""" a = AliquotType(name="aliquot_a", numeric_code="55", alpha_code="AA") b = AliquotType(name="aliquot_b", numeric_code="66", alpha_code="BB") a.add_derivatives(b) process = Process(aliquot_type=b, aliquot_count=3) processing_profile = ProcessingProfile(name="process", aliquot_type=a) processing_profile.add_processes(process) panel = RequisitionPanel(name="Viral Load", processing_profile=processing_profile) lab_profile = LabProfile( name="profile", requisition_model="edc_lab.subjectrequisition") lab_profile.add_panel(panel) panel = lab_profile.panels.get("Viral Load") self.assertEqual(panel.requisition_model, "edc_lab.subjectrequisition") self.assertEqual(panel.requisition_model_cls, SubjectRequisition)
class TestRequisitionModel(TestCase): @classmethod def setUpClass(cls): add_or_update_django_sites( sites=[ SingleSite( settings.SITE_ID, "test_site", country_code="ug", country="uganda", domain="bugamba.ug.clinicedc.org", ) ] ) return super().setUpClass() def setUp(self): self.requisition_model = "edc_lab.subjectrequisition" a = AliquotType(name="aliquot_a", numeric_code="55", alpha_code="AA") b = AliquotType(name="aliquot_b", numeric_code="66", alpha_code="BB") a.add_derivatives(b) process = Process(aliquot_type=b, aliquot_count=3) processing_profile = ProcessingProfile(name="process", aliquot_type=a) processing_profile.add_processes(process) panel = RequisitionPanel(name="Viral Load", processing_profile=processing_profile) self.lab_profile = LabProfile(name="profile", requisition_model=self.requisition_model) self.lab_profile.add_panel(panel) site_labs._registry = {} site_labs.loaded = False site_labs.register(lab_profile=self.lab_profile) def test_(self): obj = site_labs.get(lab_profile_name="profile") self.assertEqual(obj, self.lab_profile) def test_lab_profile_model(self): obj = site_labs.get(lab_profile_name="profile") self.assertEqual(self.requisition_model, obj.requisition_model) def test_panel_model(self): for panel in site_labs.get(lab_profile_name="profile").panels.values(): self.assertEqual(panel.requisition_model, self.requisition_model)
def test_site_labs_register(self): lab_profile = LabProfile( name="lab_profile", requisition_model="edc_lab.subjectrequisition") site_lab = SiteLabs() site_lab.register(lab_profile) self.assertTrue(site_lab.loaded)
def test_str(self): obj = LabProfile(name="profile", requisition_model="edc_lab.subjectrequisition") self.assertTrue(str(obj))