class LoadPresenterTest(unittest.TestCase):
    def setUp(self):
        self._qapp = mock_widget.mockQapp()

        self._view = mock.create_autospec(LoadView)
        self._load_model = mock.create_autospec(LoadModel)
        self._co_model = mock.create_autospec(CoLoadModel)
        self.presenter = LoadPresenter(
            self._view, self._load_model, self._co_model)
        self.view = self.presenter.view

    def test_equalise_loaded_runs(self):
        self.presenter.co_model.loaded_runs = 5
        self.presenter.load_model.loaded_runs = 10
        self.presenter.equalise_loaded_runs()
        self.assertEquals(self.presenter.co_model.loaded_runs, 10)

    def test_update_models(self):
        self.presenter.load_model = LoadModel()
        self.presenter.co_model = CoLoadModel()
        test_value = 10
        self.presenter.update_models(test_value)
        self.assertEquals(self.presenter.load_model.run, test_value)
        self.assertEquals(self.presenter.co_model.run, test_value)

    def test_enable_buttons(self):
        self.presenter.enable_buttons()
        self.assertEquals(self.view.enable_buttons.call_count, 1)

    def test_disable_buttons(self):
        self.presenter.disable_buttons()
        self.assertEquals(self.view.disable_buttons.call_count, 1)
Пример #2
0
class LoadPresenterTest(unittest.TestCase):
    def setUp(self):
        self._qapp = mock_widget.mockQapp()

        self._view = mock.create_autospec(LoadView)
        self._load_model = mock.create_autospec(LoadModel)
        self._co_model = mock.create_autospec(CoLoadModel)
        self.presenter = LoadPresenter(self._view, self._load_model,
                                       self._co_model)
        self.view = self.presenter.view

    def test_equalise_loaded_runs(self):
        self.presenter.co_model.loaded_runs = 5
        self.presenter.load_model.loaded_runs = 10
        self.presenter.equalise_loaded_runs()
        self.assertEquals(self.presenter.co_model.loaded_runs, 10)

    def test_update_models(self):
        self.presenter.load_model = LoadModel()
        self.presenter.co_model = CoLoadModel()
        test_value = 10
        self.presenter.update_models(test_value)
        self.assertEquals(self.presenter.load_model.run, test_value)
        self.assertEquals(self.presenter.co_model.run, test_value)

    def test_enable_buttons(self):
        self.presenter.enable_buttons()
        self.assertEquals(self.view.enable_buttons.call_count, 1)

    def test_disable_buttons(self):
        self.presenter.disable_buttons()
        self.assertEquals(self.view.disable_buttons.call_count, 1)
Пример #3
0
class LoadPresenterTest(unittest.TestCase):
    def setUp(self):
        self._view = mock.create_autospec(LoadView)
        self._load_model = mock.create_autospec(LoadModel)
        self._co_model = mock.create_autospec(CoLoadModel)
        self.presenter = LoadPresenter(
        self._view, self._load_model, self._co_model)
        self.view = self.presenter.view

    def test_equalise_last_loaded_run_empty(self):
        runs = OrderedDict()
        self.presenter.co_model.loaded_runs = runs
        self.presenter.load_model.loaded_runs = runs
        self.presenter.equalise_last_loaded_run(runs)
        self.assertEqual(self.presenter._current_run, None)

    def test_equalise_last_loaded_run_data(self):
        # need to add each in tern for Python 2
        runs = OrderedDict()
        runs[1]=[]
        runs[2] =[]
        runs[5] =[]
        runs[3]=[]
        self.presenter.co_model.loaded_runs = runs
        self.presenter.load_model.loaded_runs = runs
        self.presenter.equalise_last_loaded_run(runs)
        self.assertEqual(self.presenter._current_run, '3')

    def test_update_models(self):
        self.presenter.load_model = LoadModel()
        self.presenter.co_model = CoLoadModel()
        test_value = 10
        self.presenter.update_models(test_value)
        self.assertEqual(self.presenter.load_model.run, test_value)
        self.assertEqual(self.presenter.co_model.run, test_value)

    def test_enable_buttons(self):
        self.presenter.enable_buttons()
        self.assertEqual(self.view.enable_buttons.call_count, 1)

    def test_disable_buttons(self):
        self.presenter.disable_buttons()
        self.assertEqual(self.view.disable_buttons.call_count, 1)

    def test_set_coadd_loaded_run(self):
        self.presenter.equalise_last_loaded_run = mock.Mock()
        runs = OrderedDict()
        self.presenter.co_model.loaded_runs = runs
        self.presenter.load_model.loaded_runs = OrderedDict()
        self.presenter.set_coadd_loaded_run()
        self.presenter.equalise_last_loaded_run.assert_called_with(runs.keys())      

    def test_set_loaded_run(self):
        self.presenter.equalise_last_loaded_run = mock.Mock()
        runs = OrderedDict()
        self.presenter.co_model.loaded_runs = OrderedDict()
        self.presenter.load_model.loaded_runs = runs
        self.presenter.set_loaded_run()
        self.presenter.equalise_last_loaded_run.assert_called_with(runs.keys())      

    def test_end_load_thread(self):
        self.presenter.set_loaded_run = mock.Mock()
        self.presenter.enable_buttons = mock.Mock()
        self.presenter.load_thread = mock.Mock()
        self.presenter.load_thread.deleteLater = mock.Mock()

        self.presenter.end_load_thread()
        self.assertEqual(self.presenter.set_loaded_run.call_count, 1)
        self.assertEqual(self.presenter.enable_buttons.call_count, 1)
        self.assertEqual(self.presenter.load_thread, None)

    def test_end_co_thread(self):
        self.presenter.set_coadd_loaded_run = mock.Mock()
        self.presenter.enable_buttons = mock.Mock()
        self.presenter.co_thread = mock.Mock()
        self.presenter.co_thread.deleteLater = mock.Mock()

        self.presenter.end_co_thread()
        self.assertEqual(self.presenter.set_coadd_loaded_run.call_count, 1)
        self.assertEqual(self.presenter.enable_buttons.call_count, 1)
        self.assertEqual(self.presenter.co_thread, None)

    def test_last_loaded_run(self):
        self.presenter._current_run = 5
        self.assertEquals(self.presenter.last_loaded_run(), 5)