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["run_id"] = RunID(params)

        for property_name in ["plate_barcode", "run_id"]:
            self.properties[property_name].is_valid()

        self.properties["run_info"] = RunInfo(self.properties["run_id"])
        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["automation_system_name"] = AutomationSystemName(
            self.properties["run_info"])
        self.properties["robot_uuid"] = RobotUUID(
            self.properties["automation_system_name"])
        self.properties["user_id"] = UserID(self.properties["run_info"])
def test_samples_picked_from_source_valid(app):
    assert (
        SamplesPickedFromSource(
            PlateBarcode({FIELD_EVENT_BARCODE: "aBarcode"}), RunID({FIELD_EVENT_RUN_ID: "5"})
        ).is_valid()
        is True
    )
    assert (
        SamplesPickedFromSource(
            PlateBarcode(
                {
                    "missing_barcode_field": "aBarcode",
                }
            ),
            RunID({FIELD_EVENT_RUN_ID: "5"}),
        ).is_valid()
        is False
    )
def test_user_id_value_unsuccessful(app, mocked_responses, cherrytrack_mock_run_info):
    with app.app_context():
        myExc = None
        robot = AutomationSystemName(RunInfo(RunID({FIELD_EVENT_RUN_ID: 5})))
        try:
            robot.value
        except Exception as exc:
            myExc = exc

        msg = "Response from Cherrytrack is not OK: Failed to get automation system run info for the given run id"
        assert msg == str(myExc)
        assert ["Exception during retrieval: " + msg] == robot.errors
def test_samples_picked_from_source_no_lh_sample_uuids(
    app, run_id, source_barcode, mocked_responses, cherrytrack_mock_source_plates
):
    with app.app_context():
        with patch("lighthouse.classes.services.mongo.app.data.driver.db.samples") as samples_collection:
            val = SamplesPickedFromSource(
                PlateBarcode({FIELD_EVENT_BARCODE: source_barcode}), RunID({FIELD_EVENT_RUN_ID: run_id})
            ).value

            samples_collection.find.assert_not_called()
            assert val == []
            assert len(val) == 0
示例#5
0
def test_user_id_value_unsuccessful(app, mocked_responses,
                                    cherrytrack_mock_run_info):
    with app.app_context():
        exception = None
        user_id = UserID(RunInfo(RunID({FIELD_EVENT_RUN_ID: 5})))
        try:
            user_id.value
        except Exception as e:
            exception = e

        msg = "Response from Cherrytrack is not OK: Failed to get automation system run info for the given run id"
        assert msg == str(exception)
        assert len(user_id.errors) == 1
        assert ["Exception during retrieval: " + msg] == user_id.errors
def test_samples_picked_from_source_value_unsuccessful(
    app, run_id, source_barcode, mocked_responses, cherrytrack_mock_source_plates
):
    with app.app_context():
        myExc = None
        with raises(Exception) as exc:
            myExc = exc
            SamplesPickedFromSource(
                PlateBarcode({FIELD_EVENT_BARCODE: source_barcode}), RunID({FIELD_EVENT_RUN_ID: run_id})
            ).value

        assert "Response from Cherrytrack is not OK: Failed to get samples for the given source plate barcode." == str(
            myExc.value  # type: ignore
        )
示例#7
0
    def initialize_event(self, params: Dict[str, str]) -> None:
        super().initialize_event(params=params)

        self._event_type = params["event_type"]

        self.properties["run_id"] = RunID(params)

        for property_name in ["run_id"]:
            self.properties[property_name].is_valid()

        self.properties["run_info"] = RunInfo(self.properties["run_id"])
        self.properties["user_id"] = UserID(self.properties["run_info"])
        self.properties["automation_system_name"] = AutomationSystemName(self.properties["run_info"])
        self.properties["robot_uuid"] = RobotUUID(self.properties["automation_system_name"])
def test_robot_serial_number_value_successful(app, run_id, mocked_responses, cherrytrack_mock_run_info):
    with app.app_context():

        expected_response = {
            "data": {
                "id": run_id,
                FIELD_CHERRYTRACK_USER_ID: "user1",
                FIELD_CHERRYTRACK_LIQUID_HANDLER_SERIAL_NUMBER: "aLiquidHandlerSerialNumber",
                FIELD_CHERRYTRACK_AUTOMATION_SYSTEM_MANUFACTURER: "biosero",
                FIELD_CHERRYTRACK_AUTOMATION_SYSTEM_NAME: "CPA",
            }
        }

        val = AutomationSystemName(RunInfo(RunID({FIELD_EVENT_RUN_ID: run_id}))).value

        assert val == expected_response["data"][FIELD_CHERRYTRACK_AUTOMATION_SYSTEM_NAME]
    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["run_id"] = RunID(params)

        for property_name in ["plate_barcode", "run_id"]:
            self.properties[property_name].is_valid()

        self.properties["run_info"] = RunInfo(self.properties["run_id"])
        self.properties["source_plate_uuid"] = SourcePlateUUID(self.properties["plate_barcode"])
        self.properties["user_id"] = UserID(self.properties["run_info"])
        self.properties["automation_system_name"] = AutomationSystemName(self.properties["run_info"])
        self.properties["robot_uuid"] = RobotUUID(self.properties["automation_system_name"])
        self.properties["all_samples"] = SamplesFromSource(self.properties["plate_barcode"])
    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["run_id"] = RunID(params)

        for property_name in ["plate_barcode", "run_id"]:
            self.properties[property_name].is_valid()

        self.properties["run_info"] = RunInfo(self.properties["run_id"])
        self.properties["user_id"] = UserID(self.properties["run_info"])
        self.properties["automation_system_name"] = AutomationSystemName(
            self.properties["run_info"])
        self.properties["robot_uuid"] = RobotUUID(
            self.properties["automation_system_name"])
        self.properties["barcode_no_plate_map_data"] = BarcodeNoPlateMapData(
            params)
def test_samples_picked_from_source_value_successful(
    app,
    run_id,
    source_barcode,
    destination_barcode,
    cherrytrack_source_plates_response,
    mocked_responses,
    cherrytrack_mock_source_plates,
    samples_from_cherrytrack_into_mongo,
):
    with app.app_context():
        val = SamplesPickedFromSource(
            PlateBarcode({FIELD_EVENT_BARCODE: source_barcode}), RunID({FIELD_EVENT_RUN_ID: run_id})
        ).value
        samples, _ = samples_from_cherrytrack_into_mongo

        for elem in val:
            del elem["_id"]
            del elem["Date Tested"]
        for elem in samples:
            del elem["_id"]
            del elem["Date Tested"]
        assert val == [samples[0], samples[2]]
        assert len(val) == 2
示例#12
0
def test_user_id_valid(app):
    assert UserID(RunInfo(RunID({FIELD_EVENT_RUN_ID: 1}))).is_valid() is True
def test_robot_serial_number_valid(app):
    assert AutomationSystemName(RunInfo(RunID({FIELD_EVENT_RUN_ID: 1}))).is_valid() is True
示例#14
0
def test_robot_serial_number_valid(app):
    assert RobotSerialNumber(RunInfo(RunID({FIELD_EVENT_RUN_ID: 1
                                            }))).is_valid() is True
def test_run_info_valid(app):
    assert RunInfo(RunID({FIELD_EVENT_RUN_ID: 1})).is_valid() is True