コード例 #1
0
 def setUp(self):
     DatabaseFixture.setUp(self)
     LogTestCase.setUp(self)
     self.client = Client.__new__(Client)
     from threading import Lock
     self.client.lock = Lock()
     self.client.task_tester = None
     self.logic = GuiApplicationLogic()
     self.app = Gui(self.logic, AppMainWindow)
コード例 #2
0
ファイル: startgui.py プロジェクト: scorpilix/Golemtest
    def __init__(self, rendering):

        from gui.application import Gui
        from gui.applicationlogic import GuiApplicationLogic
        from gui.controller.mainwindowcustomizer import MainWindowCustomizer
        from gui.view.appmainwindow import AppMainWindow

        self.logic = GuiApplicationLogic()
        self.gui = Gui(self.logic, AppMainWindow)
        self.logic.register_gui(self.gui.get_main_window(),
                                MainWindowCustomizer)

        if rendering:
            register_rendering_task_types(self.logic)
コード例 #3
0
 def setUp(self):
     TestDirFixtureWithReactor.setUp(self)
     self.client = Client.__new__(Client)
     from threading import Lock
     self.client.lock = Lock()
     self.client.task_tester = None
     self.logic = GuiApplicationLogic()
     self.app = Gui(self.logic, AppMainWindow)
コード例 #4
0
    def test_get_environments(self):
        from apps.appsmanager import AppsManager

        logic = GuiApplicationLogic()
        logic.customizer = Mock()
        logic.client = self.client

        apps_manager = AppsManager()
        apps_manager.load_apps()

        for env in apps_manager.get_env_list():
            self.client.environments_manager.add_environment(env)

        environments = sync_wait(logic.get_environments())

        assert len(environments) > 0
        assert all([bool(env) for env in environments])
        assert all([isinstance(env, dict) for env in environments])
コード例 #5
0
class TestBlenderRenderDialogCustomizer(TestDirFixture):

    def setUp(self):
        super(TestBlenderRenderDialogCustomizer, self).setUp()
        self.logic = GuiApplicationLogic()
        self.gui = Gui(Mock(), AppMainWindow)

    def tearDown(self):
        super(TestBlenderRenderDialogCustomizer, self).tearDown()
        self.gui.app.exit(0)
        self.gui.app.deleteLater()

    @patch("gui.controller.customizer.QMessageBox")
    def test_blender_customizer(self, mock_messagebox):
        self.logic.customizer = MainWindowCustomizer(self.gui.main_window,
                                                     self.logic)
        self.logic.register_new_task_type(
            BlenderTaskTypeInfo(TaskWidget(Ui_BlenderWidget),
                                BlenderRenderDialogCustomizer))
        self.logic.client = Mock()
        self.logic.client.config_desc = ClientConfigDescriptor()
        self.logic.client.config_desc.use_ipv6 = False
        self.logic.client.config_desc.max_price = 0
        self.logic.client.get_config.return_value = self.logic.client.config_desc
        self.logic.client.get_res_dirs.return_value = {'computing': self.path, 'received': self.path}
        self.logic.customizer.init_config()
        customizer = self.logic.customizer.new_task_dialog_customizer.task_customizer

        assert isinstance(customizer, FrameRendererCustomizer)
        assert not customizer.gui.ui.framesCheckBox.isChecked()
        customizer._change_options()
        assert customizer.options.frames == range(1, 11)
        customizer.gui.ui.framesCheckBox.setChecked(True)
        customizer.gui.ui.framesLineEdit.setText(u"{}".format("1;3;5-12"))
        customizer._change_options()
        assert customizer.options.frames == [1, 3] + range(5, 13)
        customizer.gui.ui.framesLineEdit.setText(u"{}".format("Not proper frames"))
        customizer._change_options()
        assert customizer.options.frames == [1, 3] + range(5, 13)
        mock_messagebox.assert_called_with(mock_messagebox.Critical, "Error",
                                           u"Wrong frame format. Frame list expected, e.g. 1;3;5-12.",
                                           ANY, ANY)
コード例 #6
0
ファイル: startgui.py プロジェクト: scorpilix/Golemtest
class GUIApp(object):
    def __init__(self, rendering):

        from gui.application import Gui
        from gui.applicationlogic import GuiApplicationLogic
        from gui.controller.mainwindowcustomizer import MainWindowCustomizer
        from gui.view.appmainwindow import AppMainWindow

        self.logic = GuiApplicationLogic()
        self.gui = Gui(self.logic, AppMainWindow)
        self.logic.register_gui(self.gui.get_main_window(),
                                MainWindowCustomizer)

        if rendering:
            register_rendering_task_types(self.logic)

    @inlineCallbacks
    def start(self, client):
        yield self.logic.register_client(client)
        yield self.logic.start()
        self.gui.execute()
コード例 #7
0
 def test_start_task(self):
     logic = GuiApplicationLogic()
     logic.customizer = Mock()
     logic.client = Mock()
     task_desc = TaskDesc()
     task_desc.task_state.status = TaskStatus.notStarted
     task_desc.definition.task_type = "TASKTYPE1"
     task_type = Mock()
     task_type.task_builder_type.return_value = TTaskBuilder(self.path)
     logic.task_types["TASKTYPE1"] = task_type
     logic.tasks["xyz"] = task_desc
     logic.start_task("xyz")
     assert task_desc.task_state.status == TaskStatus.starting
     assert task_desc.task_state.outputs == [
         "output1", "output2", "output3"
     ]
コード例 #8
0
    def test_update_payments_view(self):
        logic = GuiApplicationLogic()
        logic.client = Mock()
        logic.customizer = Mock()
        ether = denoms.ether

        balance_deferred = Deferred()
        balance_deferred.result = (3 * ether, 1 * ether, 0.3 * ether)
        balance_deferred.called = True

        logic.client.get_balance.return_value = balance_deferred
        logic.update_payments_view()

        ui = logic.customizer.gui.ui
        ui.localBalanceLabel.setText.assert_called_once_with("3.00000000 GNT")
        ui.reservedBalanceLabel.setText.assert_called_once_with(
            "2.00000000 GNT")
        ui.availableBalanceLabel.setText.assert_called_once_with(
            "1.00000000 GNT")
        ui.depositBalanceLabel.setText.assert_called_once_with(
            "0.30000000 ETH")
コード例 #9
0
 def setUp(self):
     super(TestAddResourcesDialogCustomizer, self).setUp()
     self.logic = GuiApplicationLogic()
     self.gui = Gui(self.logic, AppMainWindow)
コード例 #10
0
 def setUp(self):
     super(TestTaskDetailsDialogCustomizer, self).setUp()
     self.logic = GuiApplicationLogic()
     self.gui = Gui(self.logic, AppMainWindow)
コード例 #11
0
class TestNewTaskDialogCustomizer(TempDirFixture, LogTestCase):

    def setUp(self):
        super(TestNewTaskDialogCustomizer, self).setUp()
        self.logic = GuiApplicationLogic()
        self.gui = Gui(self.logic, AppMainWindow)

    def tearDown(self):
        super(TestNewTaskDialogCustomizer, self).tearDown()
        self.gui.app.exit(0)
        self.gui.app.deleteLater()

    def test_customizer(self):

        self.logic.client = Mock()
        self.logic.client.config_desc = Mock()
        self.logic.client.config_desc.max_price = 0
        self.logic.client.get_config.return_value = self.logic.client.config_desc
        self.logic.dir_manager = Mock()
        self.logic.dir_manager.root_path = self.path

        tti = TaskTypeInfo("Nice task", TaskDefinition, CoreTaskDefaults(), Mock(),
                           Mock(), Mock(), Mock())
        self.logic.register_new_task_type(tti)
        self.gui.main_window.ui.taskSpecificLayout = Mock()
        self.gui.main_window.ui.taskSpecificLayout.count.return_value = 2
        customizer = NewTaskDialogCustomizer(self.gui.main_window, self.logic)
        self.assertIsInstance(customizer, NewTaskDialogCustomizer)
        assert customizer.gui.ui.showAdvanceNewTaskButton.text() == customizer.SHOW_ADVANCE_BUTTON_MESSAGE[0]
        assert not customizer.gui.ui.advanceNewTaskWidget.isVisible()
        customizer._advance_settings_button_clicked()
        QTest.mouseClick(customizer.gui.ui.showAdvanceNewTaskButton, Qt.LeftButton)

        task_name = "Some Nice Task"
        td = TaskDefinition()
        td.resources = ["/abc/./def", "/ghi/jik"]
        td.main_program_file = "/a/b/c/"
        td.task_name = task_name
        td.main_scene_file = 'a/b/c/d e/file.blend'
        td.task_type = "Nice task"
        td.output_file = 'a/b/c/d e/result.jpeg'
        win_norm_resources = {"\\abc\\def", "\\ghi\\jik"}
        oth_norm_resources = {"/abc/def", "/ghi/jik"}
        customizer.load_task_definition(td)
        if is_windows():
            assert customizer.add_task_resource_dialog_customizer.resources == win_norm_resources
        else:
            assert customizer.add_task_resource_dialog_customizer.resources == oth_norm_resources
        assert customizer.gui.ui.taskNameLineEdit.text() == task_name

        assert td.resources == ["/abc/./def", "/ghi/jik"]
        customizer._read_basic_task_params(td)
        if is_windows():
            assert td.resources == win_norm_resources
        else:
            assert td.resources == oth_norm_resources
        assert td.task_name == task_name

        reg = re.compile('Nice task_[0-2]\d:[0-5]\d:[0-5]\d_20\d\d-[0-1]\d\-[0-3]\d')
        td.task_name = None
        customizer.load_task_definition(td)
        name = "{}".format(customizer.gui.ui.taskNameLineEdit.text())
        assert re.match(reg, name) is not None, "Task name does not match: {}".format(name)

        td.task_name = ""
        customizer.load_task_definition(td)
        name = "{}".format(customizer.gui.ui.taskNameLineEdit.text())
        assert re.match(reg, name) is not None, "Task name does not match: {}".format(name)

    @patch('apps.core.gui.controller.newtaskdialogcustomizer.QFileDialog')
    def test_customizer(self, file_dialog_mock):
        self.logic.client = Mock()
        self.logic.client.config_desc = Mock()
        self.logic.client.config_desc.max_price = 0
        self.logic.client.get_config.return_value = self.logic.client.config_desc
        self.logic.dir_manager = Mock()
        self.logic.dir_manager.root_path = self.path
        self.logic.customizer = Mock()

        register_task_types(self.logic)
        customizer = NewTaskDialogCustomizer(self.gui.main_window, self.logic)
        self.assertIsInstance(customizer, NewTaskDialogCustomizer)

        definition = RenderingTaskDefinition()
        renderer = BlenderTaskTypeInfo(Mock(), Mock())
        assert renderer.name == "Blender"
        assert renderer.options is not None
        definition.task_type = renderer.name
        definition.options = Mock()
        definition.options.use_frames = False
        definition.options.compositing = False
        resources = self.additional_dir_content([3])
        definition.resources = set(resources)
        self.logic.customizer = Mock()
        self.logic.task_types[renderer.name] = renderer
        customizer.load_task_definition(definition)
        with self.assertRaises(TypeError):
            customizer.load_task_definition(None)
        self.assertEqual(len(definition.resources), 3)
        customizer.gui.ui.taskNameLineEdit.setText("NEW NAME")
        definition2 = customizer._query_task_definition()
        self.assertEqual(definition2.task_name, "NEW NAME")
        file_dialog_mock.getOpenFileName.return_value = "/abc/def/ghi"

        definition.task_type = "UNKNOWN"
        with self.assertLogs(logger, level="ERROR"):
            customizer._load_task_type(definition)

        options = Options()
        customizer.set_options(options)
        assert customizer.logic.options == options

        customizer._NewTaskDialogCustomizer__test_task_button_clicked()
        customizer.test_task_computation_finished(True, 103139)
        self.assertEqual(customizer.task_state.definition.estimated_memory, 103139)
        self.assertTrue(customizer.gui.ui.finishButton.isEnabled())
        customizer._show_add_resource_dialog()
        self.assertFalse(customizer.gui.ui.finishButton.isEnabled())

        customizer._open_options()
コード例 #12
0
class TestGuiApplicationLogicWithGUI(DatabaseFixture, LogTestCase):
    def setUp(self):
        DatabaseFixture.setUp(self)
        LogTestCase.setUp(self)
        self.client = Client.__new__(Client)
        from threading import Lock
        self.client.lock = Lock()
        self.client.task_tester = None
        self.logic = GuiApplicationLogic()
        self.app = Gui(self.logic, AppMainWindow)

    def tearDown(self):
        self.app.app.exit(0)
        self.app.app.deleteLater()
        LogTestCase.tearDown(self)
        DatabaseFixture.tearDown(self)

    def test_updating_config_dialog(self):
        logic = self.logic
        app = self.app
        logic.client = Mock()
        logic.register_gui(app.get_main_window(), MainWindowCustomizer)

        logic.lock_config(True)

        self.assertFalse(logic.customizer.gui.ui.settingsOkButton.isEnabled())
        self.assertFalse(
            logic.customizer.gui.ui.settingsCancelButton.isEnabled())

        logic.lock_config(True)
        logic.lock_config(False)
        logic.lock_config(False)

        self.assertTrue(logic.customizer.gui.ui.settingsOkButton.isEnabled())
        self.assertTrue(
            logic.customizer.gui.ui.settingsCancelButton.isEnabled())

    def test_main_window(self):
        self.app.main_window.ui.taskTableWidget.setColumnWidth = Mock()
        self.app.main_window.show()

        n = self.app.main_window.ui.taskTableWidget.columnCount()

        set_width = self.app.main_window.ui.taskTableWidget.setColumnWidth
        set_width.assert_has_calls([call(i, ANY) for i in xrange(0, n)])

    def test_update_peers_view(self):
        logic = self.logic
        gui = self.app
        logic.customizer = MainWindowCustomizer(gui.main_window, logic)
        logic.customizer.new_task_dialog_customizer = Mock()
        peer = Mock()
        peer.address = "10.10.10.10"
        peer.port = 1031
        peer.key_id = "KEYID"
        peer.node_name = "NODE 1"
        peer2 = Mock()
        peer2.address = "10.10.10.20"
        peer2.port = 1034
        peer2.key_id = "KEYID2"
        peer2.node_name = "NODE 2"
        logic._update_peers_view(
            [DictSerializer.dump(peer),
             DictSerializer.dump(peer2)])
        table = logic.customizer.gui.ui.connectedPeersTable
        self.assertEqual(table.rowCount(), 2)
        self.assertEqual(table.item(0, 0).text(), "10.10.10.10")
        self.assertEqual(table.item(1, 0).text(), "10.10.10.20")
        self.assertEqual(table.item(0, 1).text(), "1031")
        self.assertEqual(table.item(1, 1).text(), "1034")
        self.assertEqual(table.item(0, 2).text(), "KEYID")
        self.assertEqual(table.item(1, 2).text(), "KEYID2")
        self.assertEqual(table.item(0, 3).text(), "NODE 1")
        self.assertEqual(table.item(1, 3).text(), "NODE 2")

    def test_change_verification_options(self):
        logic = self.logic
        logic.client = Mock()
        logic.client.datadir = self.path
        self.logic.customizer = MainWindowCustomizer(self.app.main_window,
                                                     self.logic)
        prev_y = logic.customizer.gui.ui.verificationSizeYSpinBox.maximum()
        logic.change_verification_option(size_x_max=914)
        self.assertEqual(
            logic.customizer.gui.ui.verificationSizeXSpinBox.maximum(), 914)
        self.assertEqual(
            logic.customizer.gui.ui.verificationSizeYSpinBox.maximum(), prev_y)
        logic.change_verification_option(size_y_max=123)
        self.assertEqual(
            logic.customizer.gui.ui.verificationSizeXSpinBox.maximum(), 914)
        self.assertEqual(
            logic.customizer.gui.ui.verificationSizeYSpinBox.maximum(), 123)
        logic.change_verification_option(size_y_max=3190, size_x_max=134)
        self.assertEqual(
            logic.customizer.gui.ui.verificationSizeXSpinBox.maximum(), 134)
        self.assertEqual(
            logic.customizer.gui.ui.verificationSizeYSpinBox.maximum(), 3190)

    @ci_skip
    @patch('PyQt5.QtWidgets.QMessageBox')
    def test_messages(self, msg_box):
        msg_box.return_value = msg_box
        logic = self.logic
        self.logic.datadir = self.path
        logic.customizer = MainWindowCustomizer(self.app.main_window, logic)
        logic.customizer.show_error_window = Mock()
        logic.customizer.show_warning_window = Mock()
        logic.customizer.current_task_highlighted = Mock()
        logic.client = Mock()
        self.logic.dir_manager = DirManager(self.path)
        register_task_types(logic)

        rts = TaskDesc()
        self.assertIsInstance(rts, TaskDesc)
        f = self.additional_dir_content([3])
        rts.definition.task_type = "Blender"
        rts.definition.output_file = f[0]
        rts.definition.main_program_file = f[1]
        rts.definition.main_scene_file = f[2]
        self.assertTrue(logic._validate_task_state(rts))
        m = Mock()

        broken_benchmark = BlenderBenchmark()
        broken_benchmark.task_definition.main_program_file = u'Bździągwa'
        logic.customizer.show_error_window = Mock()
        logic.run_benchmark(broken_benchmark, m, m)
        logic.progress_dialog.close()
        if logic.br.tt:
            logic.br.tt.join()
        logic.customizer.show_error_window.assert_called_with(
            u"Main program file does not exist: Bździągwa")

        broken_benchmark = BlenderBenchmark()
        broken_benchmark.task_definition.output_file = u'/x/y/Bździągwa'
        logic.run_benchmark(broken_benchmark, m, m)
        logic.progress_dialog.close()
        if logic.br.tt:
            logic.br.tt.join()
        logic.customizer.show_error_window.assert_called_with(
            u"Cannot open output file: /x/y/Bździągwa")

        broken_benchmark = BlenderBenchmark()
        broken_benchmark.task_definition.main_scene_file = "NOT EXISTING"
        output_file = os.path.join(self.path, str(uuid.uuid4()))
        broken_benchmark.task_definition.output_file = output_file
        logic.run_benchmark(broken_benchmark, m, m)
        logic.progress_dialog.close()
        if logic.br.tt:
            logic.br.tt.join()
        logic.customizer.show_error_window.assert_called_with(
            u"Main scene file NOT EXISTING is not properly set")

        logic.test_task_computation_error(u"Bździągwa")
        text = logic.progress_dialog_customizer.gui.ui.message.text()
        assert text == u"Task test computation failure. Bździągwa"
        logic.test_task_computation_error(u"500 server error")
        text = logic.progress_dialog_customizer.gui.ui.message.text()
        assert text == u"Task test computation failure. [500 server error] " \
            u"There is a chance that you RAM limit is too low. " \
            u"Consider increasing max memory usage"
        logic.test_task_computation_error(None)
        text = logic.progress_dialog_customizer.gui.ui.message.text()
        assert text == u"Task test computation failure. "
        logic.test_task_computation_success([], 10000, 1021, {})
        text = logic.progress_dialog_customizer.gui.ui.message.text()
        assert text.startswith(u"Task tested successfully")
        logic.test_task_computation_success([], 10000, 1021,
                                            {"warnings": "Warning message"})
        text = logic.progress_dialog_customizer.gui.ui.message.text()
        assert text.startswith(u"Task tested successfully")
        logic.customizer.show_warning_window.assert_called_with(
            "Warning message")

        rts.definition = BlenderBenchmark().task_definition
        rts.definition.output_file = 1342
        self.assertFalse(logic._validate_task_state(rts))

        self.assertEqual(logic._format_stats_message(("STAT1", 2424)),
                         u"Session: STAT1; All time: 2424")
        self.assertEqual(logic._format_stats_message(["STAT1"]), u"Error")
        self.assertEqual(logic._format_stats_message(13131), u"Error")

        ts = TaskDesc()
        ts.definition.task_type = "Blender"
        ts.definition.main_program_file = "nonexisting"
        self.assertFalse(logic._validate_task_state(ts))
        logic.customizer.show_error_window.assert_called_with(
            u"Main program file does not exist: nonexisting")

        with self.assertLogs(logger, level="WARNING"):
            logic.set_current_task_type("unknown task")

        def query_task_state(*_):
            deferred = Deferred()
            deferred.callback(True)
            return deferred

        logic.client.query_task_state = query_task_state
        with self.assertLogs(logger, level="WARNING"):
            logic.task_status_changed("unknown id")

        task_type = Mock()
        task_type.name = "NAME1"
        logic.register_new_task_type(task_type)
        with self.assertLogs(int_logger, level="ERROR"):
            logic.register_new_task_type(task_type)

        logic.register_new_test_task_type(task_type)
        with self.assertRaises(RuntimeError):
            logic.register_new_test_task_type(task_type)

    def test_test_task_status(self):
        def reset():
            self.logic.test_task_started = Mock()
            self.logic.test_task_computation_success = Mock()
            self.logic.test_task_computation_error = Mock()

        args = ['first', 'second']

        reset()

        self.logic.test_task_status(TaskTestStatus.started, *args)
        self.logic.test_task_started.assert_called_with(*args)
        assert not self.logic.test_task_computation_success.called
        assert not self.logic.test_task_computation_error.called

        reset()

        self.logic.test_task_status(TaskTestStatus.success, *args)
        self.logic.test_task_computation_success.assert_called_with(*args)
        assert not self.logic.test_task_started.called
        assert not self.logic.test_task_computation_error.called

        reset()

        self.logic.test_task_status(TaskTestStatus.started, *args)
        self.logic.test_task_started.assert_called_with(*args)
        assert not self.logic.test_task_computation_success.called
        assert not self.logic.test_task_computation_error.called

        reset()

        self.logic.test_task_status("test")
        assert not self.logic.test_task_started.called
        assert not self.logic.test_task_computation_success.called
        assert not self.logic.test_task_computation_error.called
コード例 #13
0
    def test_task_status_changed(self):
        task_state = TaskState()
        task_dict = DictSerializer.dump(task_state)

        logic = GuiApplicationLogic()
        logic.tasks = dict(task_id=task_state, wrong_task=None)

        def get_logic_task(task_id):
            deferred = Deferred()
            task = logic.tasks.get(task_id)
            deferred.callback(DictSerializer.dump(task))
            return deferred

        logic.client = Mock()
        logic.client.query_task_state = Mock()
        logic.client.query_task_state.side_effect = get_logic_task

        logic.customizer = Mock()

        logic.task_status_changed('wrong_task')
        assert not logic.customizer.update_tasks.called
        assert logic.client.query_task_state.called

        logic.client.query_task_state.called = False
        logic.customizer.current_task_highlighted.definition.task_id = \
            str(uuid.uuid4())
        logic.task_status_changed(str(uuid.uuid4()))
        assert not logic.client.query_task_state.called
        assert not logic.customizer.update_task_additional_info.called

        logic.customizer.current_task_highlighted.definition.task_id = 'task_id'
        logic.task_status_changed(str(uuid.uuid4()))
        assert not logic.client.query_task_state.called
        assert not logic.customizer.update_task_additional_info.called

        logic.task_status_changed('task_id')
        assert logic.client.query_task_state.called
        assert logic.customizer.update_task_additional_info.called
        assert not logic.client.delete_task.called

        task_state.status = task_to_remove_status[0]
        logic.task_status_changed('task_id')
        assert logic.client.query_task_state.called
        assert logic.customizer.update_task_additional_info.called
        assert logic.client.delete_task.called
コード例 #14
0
    def test_add_tasks(self):
        logic = GuiApplicationLogic()
        logic.customizer = Mock()
        td = TestGuiApplicationLogicWithClient._get_task_definition()
        logic.add_task_from_definition(td)
        self.assertIn("xyz", logic.tasks, "Task was not added")
        task_state1 = TestGuiApplicationLogicWithClient._get_task_state()
        task_state2 = TestGuiApplicationLogicWithClient._get_task_state(
            task_id="abc")
        task_state3 = TestGuiApplicationLogicWithClient._get_task_state(
            task_id="def")
        logic.add_tasks([task_state1, task_state2, task_state3])
        self.assertEqual(len(logic.tasks), 3, "Incorrect number of tasks")
        self.assertIn("xyz", logic.tasks, "Task was not added")
        self.assertIn("abc", logic.tasks, "Task was not added")
        self.assertIn("def", logic.tasks, "Task was not added")
        self.assertEqual(logic.tasks["xyz"].definition.full_task_timeout, 100,
                         "Wrong task timeout")
        self.assertEqual(logic.tasks["xyz"].definition.subtask_timeout, 50,
                         "Wrong subtask timeout")
        result = logic.add_tasks([])
        self.assertIsNone(result,
                          "Returned value [{}] is not None".format(result))
        result = logic.get_test_tasks()
        self.assertEqual(result, {}, "Returned value is not empty")
        with self.assertLogs(logger):
            logic.change_timeouts("invalid", 10, 10)

        logic.config_changed()
コード例 #15
0
    def test_change_description(self):
        logic = GuiApplicationLogic()
        logic.customizer = Mock()

        rpc_session = MockRPCSession(self.client, CORE_METHOD_MAP)
        rpc_client = rpc.session.Client(rpc_session, CORE_METHOD_MAP)

        description = u"New description"

        logic.client = rpc_client
        logic.change_description(description)
        self.assertEqual(self.client.get_description(), description)

        p = logic.get_task_presets("Blender")
        assert p.result == {}
        logic.save_task_preset("NewPreset", "Blender", "Some data")
        p = logic.get_task_presets("Blender")
        assert p.result == {'NewPreset': "Some data"}
        logic.delete_task_preset("Blender", "NewPreset")
        p = logic.get_task_presets("Blender")
        assert p.result == {}
コード例 #16
0
class TestLuxRenderDialogCustomizer(TestDirFixture, LogTestCase):

    def setUp(self):
        super(TestLuxRenderDialogCustomizer, self).setUp()
        self.logic = GuiApplicationLogic()
        self.gui = Gui(Mock(), AppMainWindow)

    def tearDown(self):
        super(TestLuxRenderDialogCustomizer, self).tearDown()
        self.gui.app.exit(0)
        self.gui.app.deleteLater()

    @patch("apps.rendering.gui.controller.renderercustomizer.QFileDialog")
    def test_lux_customizer(self, mock_file_dialog):
        self.logic.register_new_task_type(LuxRenderTaskTypeInfo(
            TaskWidget(Ui_LuxWidget), LuxRenderDialogCustomizer))
        self.logic.customizer = MainWindowCustomizer(self.gui.main_window, self.logic)
        self.logic.dir_manager = Mock()
        self.logic.dir_manager.root_path = self.path
        self.logic.client = Mock()
        self.logic.client.config_desc = ClientConfigDescriptor()
        self.logic.client.config_desc.use_ipv6 = False
        self.logic.client.config_desc.max_price = 0
        self.logic.client.get_config.return_value = self.logic.client.config_desc
        self.logic.client.get_res_dirs.return_value = {'computing': self.path, 'received': self.path}
        self.logic.customizer.init_config()
        lux_customizer = self.logic.customizer.new_task_dialog_customizer.task_customizer
        assert isinstance(lux_customizer, LuxRenderDialogCustomizer)
        assert lux_customizer.get_task_name() == "LuxRender"

        self.logic.customizer.gui.ui.resourceFilesLabel.setText("124")
        QTest.mouseClick(self.logic.customizer.gui.ui.resetToDefaultButton, Qt.LeftButton)
        assert self.logic.customizer.gui.ui.resourceFilesLabel.text() == "0"

        definition = RenderingTaskDefinition()
        lux_customizer.get_task_specific_options(definition)
        lux_customizer.load_task_definition(definition)

        path = u"{}".format(str(lux_customizer.load_setting('main_scene_path', os.path.expanduser('~'))))
        mock_file_dialog.getOpenFileName.return_value = path, None
        QTest.mouseClick(lux_customizer.gui.ui.chooseMainSceneFileButton, Qt.LeftButton)
        mock_file_dialog.getOpenFileName.assert_called_with(lux_customizer.gui,
                                                            "Choose main scene file",
                                                            path,
                                                            u"Scene files (*.LXS *.lxs)")

        lux_customizer.gui.ui.stopByTimeRadioButton.setChecked(True)
        lux_customizer.gui.ui.haltTimeLineEdit.setText("60")
        lux_customizer._change_options()
        assert lux_customizer.options.haltspp == 0
        assert lux_customizer.options.halttime == 60
        lux_customizer.gui.ui.haltTimeLineEdit.setText("XYZ")
        with self.assertLogs(logger, level="ERROR"):
            lux_customizer._change_options()
        assert lux_customizer.options.haltspp == 0
        lux_customizer.gui.ui.stopBySppRadioButton.setChecked(True)
        lux_customizer.gui.ui.haltTimeLineEdit.setText("30")
        lux_customizer.gui.ui.haltSppLineEdit.setText("ABC")
        with self.assertLogs(logger, level="ERROR"):
            lux_customizer._change_options()
        assert lux_customizer.options.halttime == 0
        lux_customizer.gui.ui.haltSppLineEdit.setText("25")
        lux_customizer._change_options()
        assert lux_customizer.options.halttime == 0
        assert lux_customizer.options.haltspp == 25

        lux_customizer.options.haltspp = 0
        lux_customizer._change_halts_values()
        assert lux_customizer.gui.ui.stopByTimeRadioButton.isChecked()
        assert not lux_customizer.gui.ui.stopBySppRadioButton.isChecked()
        lux_customizer.options.haltspp = 24
        lux_customizer._change_halts_values()
        assert not lux_customizer.gui.ui.stopByTimeRadioButton.isChecked()
        assert lux_customizer.gui.ui.stopBySppRadioButton.isChecked()
コード例 #17
0
 def setUp(self):
     super(TestLuxRenderDialogCustomizer, self).setUp()
     self.logic = GuiApplicationLogic()
     self.gui = Gui(Mock(), AppMainWindow)
コード例 #18
0
 def test_root_path(self):
     logic = GuiApplicationLogic()
     self.assertTrue(os.path.isdir(logic.root_path))