def test_noneFrame(self, qtbot, mocker): cdw = CameraDataWidget() qtbot.addWidget(cdw) dc = DataController(cdw) ffModel = mocker.patch.object(dc.fullFrameModel, "calculateCentroid") dc.passFrame(None, self.fullFrameStatus) assert ffModel.call_count == 0
def test_failedFrame(self, qtbot, mocker): cdw = CameraDataWidget() qtbot.addWidget(cdw) dc = DataController(cdw) mocker.patch( 'spot_motion_monitor.views.camera_data_widget.CameraDataWidget.updateFullFrameData' ) dc.fullFrameModel.calculateCentroid = mocker.Mock( side_effect=FrameRejected) dc.passFrame(self.frame, self.fullFrameStatus) assert dc.cameraDataWidget.updateFullFrameData.call_count == 0
def test_updateRoiFrameData(self, qtbot, mocker): cdw = CameraDataWidget() qtbot.addWidget(cdw) dc = DataController(cdw) mockCameraDataWidgetReset = mocker.patch.object(cdw, 'reset') mockBufferModelUpdateInfo = mocker.patch.object( dc.bufferModel, 'updateInformation') dc.roiFrameModel.calculateCentroid = mocker.Mock( return_value=GenericFrameInformation(self.timestamp, 242.3, 286.2, 2519.534, 104.343, 11.963, 50, 1.532)) dc.passFrame(self.frame, self.roiFrameStatus) assert mockCameraDataWidgetReset.call_count == 1 assert mockBufferModelUpdateInfo.call_count == 1 dc.passFrame(self.frame, self.roiFrameStatus) assert mockCameraDataWidgetReset.call_count == 1 assert mockBufferModelUpdateInfo.call_count == 2
def test_updateFullFrameData(self, qtbot, mocker): cdw = CameraDataWidget() qtbot.addWidget(cdw) dc = DataController(cdw) mockCameraDataWidgetReset = mocker.patch.object(cdw, 'reset') mockTakeScreenshot = mocker.patch.object(dc, 'writeScreenshot') mocker.patch( 'spot_motion_monitor.views.camera_data_widget.CameraDataWidget.updateFullFrameData' ) dc.fullFrameModel.calculateCentroid = mocker.Mock( return_value=GenericFrameInformation(self.timestamp, 300.3, 400.2, 32042.42, 145.422, 17.525, 70, None)) dc.takeScreenshot = True dc.passFrame(self.frame, self.fullFrameStatus) assert dc.cameraDataWidget.updateFullFrameData.call_count == 1 assert mockCameraDataWidgetReset.call_count == 0 assert mockTakeScreenshot.call_count == 1 assert dc.roiResetDone is False dc.roiResetDone = True dc.passFrame(self.frame, self.fullFrameStatus) assert mockCameraDataWidgetReset.call_count == 1 assert dc.roiResetDone is False