def test_samples_with_cog_uk_id_from_destination_add_to_warehouse(
    app,
    run_id,
    centres,
    destination_barcode,
    samples_from_cherrytrack_into_mongo,
    mlwh_samples_in_cherrytrack,
    mocked_responses,
    cherrytrack_mock_destination_plate,
    cherrytrack_destination_plate_response,
    baracoda_mock_barcodes_group,
    baracoda_mock_responses,
):
    with app.app_context():
        samples, _ = samples_from_cherrytrack_into_mongo
        instance = SamplesWithCogUkId(
            SamplesFromDestination(WellsFromDestination(PlateBarcode({FIELD_EVENT_BARCODE: destination_barcode})))
        )
        message = WarehouseMessage("mytype", "myuuid", "at some point")
        instance.add_to_warehouse_message(message)
        assert message._subjects == [
            {
                "friendly_name": "aRootSampleId1__DS000050001_A01__centre_1__Positive",
                "role_type": "sample",
                "subject_type": "sample",
                "uuid": "aLighthouseUUID1",
            },
            {
                "friendly_name": "aRootSampleId3__DS000050001_A03__centre_1__Positive",
                "role_type": "sample",
                "subject_type": "sample",
                "uuid": "aLighthouseUUID3",
            },
        ]
Example #2
0
    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_samples_with_cog_uk_ids_from_destination_add_to_sequencescape(
    app,
    run_id,
    centres,
    destination_barcode,
    samples_from_cherrytrack_into_mongo,
    mlwh_samples_in_cherrytrack,
    mocked_responses,
    cherrytrack_mock_destination_plate,
    cherrytrack_destination_plate_response,
    baracoda_mock_barcodes_group,
    baracoda_mock_responses,
):
    with app.app_context():
        samples, _ = samples_from_cherrytrack_into_mongo
        instance = SamplesWithCogUkId(
            SamplesFromDestination(WellsFromDestination(PlateBarcode({FIELD_EVENT_BARCODE: destination_barcode})))
        )
        message = SequencescapeMessage()
        instance.add_to_sequencescape_message(message)
        assert message._contents == {
            "H08": {
                "content": {
                    "name": "DS000050001_A01",
                    "phenotype": "positive",
                    "sample_description": "aRootSampleId1",
                    "supplier_name": "COGUK1",
                    "uuid": "aLighthouseUUID1",
                }
            },
            "H12": {
                "content": {
                    "name": "DS000050001_A03",
                    "phenotype": "positive",
                    "sample_description": "aRootSampleId3",
                    "supplier_name": "COGUK2",
                    "uuid": "aLighthouseUUID3",
                }
            },
        }