def test_addGetDisplayComponent(): stage = Stage() stage.addDisplayComponent("BLORP", "location") assert stage.getDisplayComponent("BLORP") == QUrl.fromLocalFile("location") stage.addDisplayComponent("MEEP!", QUrl.fromLocalFile("MEEP")) assert stage.getDisplayComponent("MEEP!") == QUrl.fromLocalFile("MEEP")
def test_addGetDisplayComponent(): stage = Stage() stage.addDisplayComponent("BLORP", "location") assert stage.getDisplayComponent("BLORP") == QUrl.fromLocalFile("location") stage.addDisplayComponent("MEEP!", QUrl.fromLocalFile("MEEP")) assert stage.getDisplayComponent("MEEP!") == QUrl.fromLocalFile("MEEP")
def addStage(self, stage: Stage) -> None: """Add a stage if it's not already added. :param stage: The stage to be added """ name = stage.getId() if name not in self._stages: self._stages[name] = stage self.stagesChanged.emit()
def test_getStage(application): controller = Controller(application) stage_1 = Stage() stage_1.setPluginId("test_1") stage_2 = Stage() stage_2.setPluginId("test_2") controller.addStage(stage_1) controller.addStage(stage_2) assert controller.getStage("test_1") == stage_1 assert controller.getStage("test_2") == stage_2 assert controller.getStage("NOPE") is None
def test_setActiveStage(application): controller = Controller(application) controller.activeStageChanged.emit = MagicMock() stage_1 = Stage() stage_1.setPluginId("test_1") stage_1.onStageSelected = MagicMock() stage_1.onStageDeselected = MagicMock() stage_2 = Stage() stage_2.setPluginId("test_2") controller.addStage(stage_1) controller.addStage(stage_2) # Attempting to set the stage to a non existing one shouldn't do anything controller.setActiveStage("blorp") assert controller.activeStageChanged.emit.call_count == 0 # Changing it from no state to an added state should work. controller.setActiveStage("test_1") assert controller.getActiveStage() == stage_1 stage_1.onStageSelected.assert_called_once_with() # Attempting to change to a stage that doesn't exist shouldn't do anything. controller.setActiveStage("blorp") assert controller.getActiveStage() == stage_1 stage_1.onStageSelected.assert_called_once_with() stage_1.onStageDeselected.assert_not_called() # Changing to the already active stage should also not do anything. controller.setActiveStage("test_1") assert controller.getActiveStage() == stage_1 stage_1.onStageSelected.assert_called_once_with() stage_1.onStageDeselected.assert_not_called() # Actually changing it to a stage that is added and not active should have an effect controller.setActiveStage("test_2") stage_1.onStageDeselected.assert_called_with() assert controller.getActiveStage() == stage_2
def test_iconSource(): stage = Stage() # Should be empty if we didn't do anything yet assert stage.iconSource == QUrl() stage.setIconSource("DERP") assert stage.iconSource == QUrl.fromLocalFile("DERP") stage.setIconSource(QUrl.fromLocalFile("FOO")) assert stage.iconSource == QUrl.fromLocalFile("FOO")
def test_getStage(application): controller = Controller(application) stage_1 = Stage() stage_1.setPluginId("test_1") stage_2 = Stage() stage_2.setPluginId("test_2") controller.addStage(stage_1) controller.addStage(stage_2) assert controller.getStage("test_1") == stage_1 assert controller.getStage("test_2") == stage_2 assert controller.getStage("NOPE") is None
def test_setActiveStage(application): controller = Controller(application) controller.activeStageChanged.emit = MagicMock() stage_1 = Stage() stage_1.setPluginId("test_1") stage_1.onStageSelected = MagicMock() stage_1.onStageDeselected = MagicMock() stage_2 = Stage() stage_2.setPluginId("test_2") controller.addStage(stage_1) controller.addStage(stage_2) # Attempting to set the stage to a non existing one shouldn't do anything controller.setActiveStage("blorp") assert controller.activeStageChanged.emit.call_count == 0 # Changing it from no state to an added state should work. controller.setActiveStage("test_1") assert controller.getActiveStage() == stage_1 stage_1.onStageSelected.assert_called_once_with() # Attempting to change to a stage that doesn't exist shouldn't do anything. controller.setActiveStage("blorp") assert controller.getActiveStage() == stage_1 stage_1.onStageSelected.assert_called_once_with() stage_1.onStageDeselected.assert_not_called() # Changing to the already active stage should also not do anything. controller.setActiveStage("test_1") assert controller.getActiveStage() == stage_1 stage_1.onStageSelected.assert_called_once_with() stage_1.onStageDeselected.assert_not_called() # Actually changing it to a stage that is added and not active should have an effect controller.setActiveStage("test_2") stage_1.onStageDeselected.assert_called_with() assert controller.getActiveStage() == stage_2
def test_addStage(application): controller = Controller(application) stage_1 = Stage() stage_1.setPluginId("test_1") stage_2 = Stage() stage_2.setPluginId("test_1") controller.stagesChanged.emit = MagicMock() controller.addStage(stage_1) assert controller.stagesChanged.emit.call_count == 1 assert controller.getAllStages() == {"test_1": stage_1} # Adding it again shouldn't influence anything controller.addStage(stage_1) assert controller.stagesChanged.emit.call_count == 1 assert controller.getAllStages() == {"test_1": stage_1} # Adding a different stage (but with the same ID) should also not do anything! controller.addStage(stage_2) assert controller.stagesChanged.emit.call_count == 1 assert controller.getAllStages() == {"test_1": stage_1}
def test_addStage(application): controller = Controller(application) stage_1 = Stage() stage_1.setPluginId("test_1") stage_2 = Stage() stage_2.setPluginId("test_1") controller.stagesChanged.emit = MagicMock() controller.addStage(stage_1) assert controller.stagesChanged.emit.call_count == 1 assert controller.getAllStages() == {"test_1": stage_1} # Adding it again shouldn't influence anything controller.addStage(stage_1) assert controller.stagesChanged.emit.call_count == 1 assert controller.getAllStages() == {"test_1": stage_1} # Adding a different stage (but with the same ID) should also not do anything! controller.addStage(stage_2) assert controller.stagesChanged.emit.call_count == 1 assert controller.getAllStages() == {"test_1": stage_1}
def addStage(self, stage: Stage) -> None: name = stage.getPluginId() if name not in self._stages: self._stages[name] = stage self.stagesChanged.emit()
def addStage(self, stage: Stage) -> None: name = stage.getPluginId() if name not in self._stages: self._stages[name] = stage self.stagesChanged.emit()
def test_getUnknownDisplayComponent(): stage = Stage() # Just an empty QUrl assert stage.getDisplayComponent("BLORP") == QUrl()
def test_getUnknownDisplayComponent(): stage = Stage() # Just an empty QUrl assert stage.getDisplayComponent("BLORP") == QUrl()