Ejemplo n.º 1
0
    def test_process_should_create_and_start_an_upgrader_for_item_if_install_true(self, mock_AsyncActionHandler, mock_urllib2, mock_exists):
        mock_exists.return_value = False
        mock_urllib2.urlopen.return_value = self.make_mock_response(code=200, data=self.get_sample_web_config())
        expected_app = Application.from_configs(self.get_sample_application_config())
        test_installer_api = InstallerAPI('config_url')

        result = test_installer_api.initialize()
        self.assertTrue(result[0], result)
        test_installer_api.process(expected_app.id, 'base_folder', action='upgrade', status_callback='status_callback', complete_callback='complete_callback')

        mock_AsyncActionHandler.assert_called_with('upgrade', expected_app, 'base_folder', status_callback='status_callback', complete_callback='complete_callback')
        mock_AsyncActionHandler.return_value.start.assert_called_with()
Ejemplo n.º 2
0
    def test_process_should_raise_if_nothing_selected(self, mock_AsyncActionHandler, mock_urllib2, mock_exists):
        mock_exists.return_value = False
        mock_urllib2.urlopen.return_value = self.make_mock_response(code=200, data=self.get_sample_web_config())
        expected_app = Application.from_configs(self.get_sample_application_config())
        test_installer_api = InstallerAPI('config_url')

        result = test_installer_api.initialize()
        self.assertTrue(result[0], result)

        with self.assertRaises(Exception):
            test_installer_api.process(expected_app.id, 'base_folder', action='wrong', status_callback='status_callback', complete_callback='complete_callback')

        mock_AsyncActionHandler.assert_not_called()