def test_download_app_error(mock_has_min_performance, mock_download_url, mock_query_for_app): mock_query_for_app.return_value = json.loads( '{ "icon_url": "foo.bar", "min_performance_score": 1, "title": "¡Hola!" }' ) mock_has_min_performance.return_value = True mock_download_url.return_value = (True, None) install('kano-apps') with pytest.raises(AppDownloadError) as excinfo: download_app('foo') assert u'¡Hola!' in _(unicode(excinfo))
def test_download_app_error( mock_has_min_performance, mock_download_url, mock_query_for_app ): mock_query_for_app.return_value = json.loads( '{ "icon_url": "foo.bar", "min_performance_score": 1, "title": "¡Hola!" }' ) mock_has_min_performance.return_value = True mock_download_url.return_value = (True, None) install('kano-apps') with pytest.raises(AppDownloadError) as excinfo: download_app('foo') assert u'¡Hola!' in _(unicode(excinfo))
def _download_app(self): try: app_data_file, app_icon_file = download_app(self._handle) self._tmp_data_file = app_data_file self._tmp_icon_file = app_icon_file except AppDownloadError as err: head = _("Unable to download the application") dialog = KanoDialog(head, unicode(err), { _("OK"): { "return_value": 0 }, }, parent_window=self._win) dialog.run() del dialog return False self._app = load_from_app_file(self._tmp_data_file, False) return True
def _download_app(self): try: app_data_file, app_icon_file = download_app(self._handle) self._tmp_data_file = app_data_file self._tmp_icon_file = app_icon_file except AppDownloadError as err: head = "Unable to download the application" dialog = KanoDialog( head, str(err), { "OK": { "return_value": 0 }, }, parent_window=self._win ) dialog.run() del dialog return False self._app = load_from_app_file(self._tmp_data_file, False) return True