def initialize_event(self, params: Dict[str, str]) -> None: super().initialize_event(params=params) self._event_type = params["event_type"] self.properties["plate_barcode"] = PlateBarcode(params) self.properties["failure_type"] = FailureType(params) self.properties["user_id"] = UserID(params) for property_name in ["plate_barcode", "failure_type", "user_id"]: self.properties[property_name].is_valid() self.properties["destination_plate"] = self.properties["plate_barcode"] self.properties["wells"] = WellsFromDestination( self.properties["plate_barcode"]) self.properties["source_plates"] = SourcePlatesFromDestination( self.properties["wells"]) self.properties["samples"] = SamplesFromDestination( self.properties["wells"]) self.properties["samples_with_cog_uk_id"] = SamplesWithCogUkId( self.properties["samples"]) self.properties["controls"] = ControlsFromDestination( self.properties["wells"]) self.properties["run_id"] = RunIDFromWells(self.properties["wells"]) self.properties["run_info"] = RunInfo(self.properties["run_id"]) self.properties["automation_system_name"] = AutomationSystemName( self.properties["run_info"]) self.properties["robot_uuid"] = RobotUUID( self.properties["automation_system_name"])
def test_all_controls_from_destination_value_fails_with_missing_controls( app, destination_barcode, mocked_responses, cherrytrack_mock_destination_plate, ): with app.app_context(): instance = ControlsFromDestination( WellsFromDestination(PlateBarcode({FIELD_EVENT_BARCODE: destination_barcode})) ) assert instance.is_valid() is True assert instance.errors == [] with pytest.raises(Exception): instance.value assert instance.is_valid() is False assert instance.errors == [ ("Exception during retrieval: We were expecting one positive and one negative control to be present.") ]
def test_all_controls_from_destination_value_gets_value( app, run_id, destination_barcode, samples_from_cherrytrack_into_mongo, mocked_responses, cherrytrack_mock_destination_plate, cherrytrack_destination_plate_response, ): with app.app_context(): wells = cherrytrack_destination_plate_response["data"]["wells"] val = ControlsFromDestination( WellsFromDestination(PlateBarcode({FIELD_EVENT_BARCODE: destination_barcode})) ).value assert val == {"E10": wells[2], "E11": wells[3]}