コード例 #1
0
ファイル: TestStage.py プロジェクト: BCN3D/Uranium
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")
コード例 #2
0
ファイル: TestStage.py プロジェクト: Ultimaker/Uranium
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")
コード例 #3
0
    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()
コード例 #4
0
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
コード例 #5
0
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
コード例 #6
0
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")
コード例 #7
0
ファイル: TestController.py プロジェクト: Ultimaker/Uranium
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
コード例 #8
0
ファイル: TestController.py プロジェクト: Ultimaker/Uranium
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
コード例 #9
0
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}
コード例 #10
0
ファイル: TestController.py プロジェクト: Ultimaker/Uranium
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}
コード例 #11
0
ファイル: Controller.py プロジェクト: OktayYazgac/Uranium
 def addStage(self, stage: Stage) -> None:
     name = stage.getPluginId()
     if name not in self._stages:
         self._stages[name] = stage
         self.stagesChanged.emit()
コード例 #12
0
ファイル: Controller.py プロジェクト: Ultimaker/Uranium
 def addStage(self, stage: Stage) -> None:
     name = stage.getPluginId()
     if name not in self._stages:
         self._stages[name] = stage
         self.stagesChanged.emit()
コード例 #13
0
ファイル: TestStage.py プロジェクト: BCN3D/Uranium
def test_getUnknownDisplayComponent():
    stage = Stage()
    # Just an empty QUrl
    assert stage.getDisplayComponent("BLORP") == QUrl()
コード例 #14
0
ファイル: TestStage.py プロジェクト: Ultimaker/Uranium
def test_getUnknownDisplayComponent():
    stage = Stage()
    # Just an empty QUrl
    assert stage.getDisplayComponent("BLORP") == QUrl()