def test_show_hardware_requirements(self): self.app_mock.details.hardware_requirements = { 'hardware::video:opengl': 'yes', 'hardware::gps': 'no', } self.app_mock.details.hardware_requirements_satisfied = False self.view.show_app(self.app_mock) do_events() # ensure we have the data self.assertTrue( self.view.hardware_info.value_label.get_property("visible")) self.assertEqual( type(HardwareRequirementsBox()), type(self.view.hardware_info.value_label)) self.assertEqual( self.view.hardware_info.key, _("Also requires")) # ensure that the button is correct self.assertEqual( self.view.pkg_statusbar.button.get_label(), "Install Anyway") # and again for purchase self.app_mock.details.pkg_state = PkgStates.NEEDS_PURCHASE self.view.show_app(self.app_mock) self.assertEqual( self.view.pkg_statusbar.button.get_label(), _(u"Buy Anyway\u2026").encode("utf-8")) # check if the warning bar is displayed self.assertTrue(self.view.pkg_warningbar.get_property("visible")) self.assertEqual(self.view.pkg_warningbar.label.get_text(), _('This software requires a GPS, ' 'but the computer does not have one.'))
def _make_statusbar_view_for_state(self, state): app_details = make_purchased_app_details(db=self.db) # XXX 2011-01-23 It's unfortunate we need multiple mocks to test this # correctly, but I don't know the code well enough to refactor # dependencies yet so that it wouldn't be necessary. In this case, we # need a *real* app details object for displaying in the view, but want # to specify its state for the purpose of the test. As an Application # normally loads its details from the database, we patch # Application.get_details also. Patch app_details.pkg_state for the # test. pkg_state_fn = 'softwarecenter.db.application.AppDetails.pkg_state' pkg_state_patcher = patch(pkg_state_fn) self.addCleanup(pkg_state_patcher.stop) mock_pkg_state = pkg_state_patcher.start() mock_pkg_state.__get__ = Mock(return_value=state) get_details_fn = 'softwarecenter.db.application.Application.get_details' get_details_patcher = patch(get_details_fn) self.addCleanup(get_details_patcher.stop) mock_get_details = get_details_patcher.start() mock_get_details.return_value = app_details app = app_details._app details_view = self.win.get_data("view") details_view.show_app(app) do_events() statusbar_view = details_view.pkg_statusbar statusbar_view.configure(app_details, state) return statusbar_view
def test_app_store(self): # get a enquire object enquirer = AppEnquire(self.cache, self.db) enquirer.set_query(xapian.Query("")) # get a AppListStore and run functions on it model = AppListStore(self.db, self.cache, self.icons) # test if set from matches works self.assertEqual(len(model), 0) model.set_from_matches(enquirer.matches) self.assertTrue(len(model) > 0) # ensure the first row has a xapian doc type self.assertEqual(type(model[0][0]), xapian.Document) # lazy loading of the docs self.assertEqual(model[100][0], None) # test the load range stuff model.load_range(indices=[100], step=15) self.assertEqual(type(model[100][0]), xapian.Document) # ensure buffer_icons works and loads stuff into the cache model.buffer_icons() self.assertEqual(len(model.icon_cache), 0) do_events() self.assertTrue(len(model.icon_cache) > 0) # ensure clear works model.clear() self.assertEqual(model.current_matches, None)
def test_implicit_recommender_feedback_recommendations_panel_only(self): # this test insures that we only provide feedback when installing # items clicked to via the recommendations panel itself, and not # via the What's New or Top Rated panels self._opt_in_and_populate_recommended_for_you_panel() # we fake the callback from the agent here for_you = self.rec_panel.recommended_for_you_cat for_you._recommend_me_result(None, make_recommender_agent_recommend_me_dict()) do_events() post_implicit_feedback_fn = ('softwarecenter.ui.gtk3.widgets' '.recommendations.RecommenderAgent' '.post_implicit_feedback') with patch(post_implicit_feedback_fn) as mock_post_implicit_feedback: # we want to grab the app that is activated, it will be in # self._app after the app is activated on the tile click self.lobby.top_rated.connect("application-activated", self._on_application_activated) # click a tile in the Top Rated section of the lobby self._click_first_tile_in_panel(self.lobby.top_rated_frame) # simulate installing the application self._simulate_install_events(self._app) # and verify that after the install has completed we have *not* # fired the implicit feedback call to the recommender service self.assertFalse(mock_post_implicit_feedback.called)
def test_implicit_recommender_feedback_on_item_viewed(self): self._opt_in_and_populate_recommended_for_you_panel() # we fake the callback from the agent here for_you = self.rec_panel.recommended_for_you_cat for_you._recommend_me_result(None, make_recommender_agent_recommend_me_dict()) do_events() post_implicit_feedback_fn = ('softwarecenter.ui.gtk3.widgets' '.recommendations.RecommenderAgent' '.post_implicit_feedback') with patch(post_implicit_feedback_fn) as mock_post_implicit_feedback: # we want to grab the app that is activated, it will be in # self._app after the app is activated on the tile click self.rec_panel.recommended_for_you_content.connect( "application-activated", self._on_application_activated) # click a recommendation in the lobby self._click_first_tile_in_panel(self.rec_panel) # and verify that upon selecting a recommended app we have fired # the implicit feedback call to the recommender with the correct # arguments mock_post_implicit_feedback.assert_called_with( self._app.pkgname, RecommenderFeedbackActions.VIEWED)
def test_show_hardware_requirements(self): self.app_mock.details.hardware_requirements = { 'hardware::video:opengl': 'yes', 'hardware::gps': 'no', } self.app_mock.details.hardware_requirements_satisfied = False self.view.show_app(self.app_mock) do_events() # ensure we have the data self.assertTrue( self.view.hardware_info.value_label.get_property("visible")) self.assertEqual(type(HardwareRequirementsBox()), type(self.view.hardware_info.value_label)) self.assertEqual(self.view.hardware_info.key, _("Also requires")) # ensure that the button is correct self.assertEqual(self.view.pkg_statusbar.button.get_label(), "Install Anyway") # and again for purchase self.app_mock.details.pkg_state = PkgStates.NEEDS_PURCHASE self.view.show_app(self.app_mock) self.assertEqual(self.view.pkg_statusbar.button.get_label(), _(u"Buy Anyway\u2026").encode("utf-8")) # check if the warning bar is displayed self.assertTrue(self.view.pkg_warningbar.get_property("visible")) self.assertEqual( self.view.pkg_warningbar.label.get_text(), _('This software requires a GPS, ' 'but the computer does not have one.'))
def test_appmanager(self): app_manager = get_appmanager() self.assertNotEqual(app_manager, None) # test interface app_manager.reload() app = Application("", "2vcard") # call and ensure the stuff is passed to the backend app_manager.install(app, [], []) self.assertTrue(self.backend.install.called) app_manager.remove(app, [], []) self.assertTrue(self.backend.remove.called) app_manager.upgrade(app, [], []) self.assertTrue(self.backend.upgrade.called) app_manager.apply_changes(app, [], []) self.assertTrue(self.backend.apply_changes.called) app_manager.enable_software_source(app) self.assertTrue(self.backend.enable_component.called) app_manager.reinstall_purchased(app) self.assertTrue(self.backend.add_repo_add_key_and_install_app.called) # buy is special as it needs help from the purchase view app_manager.connect("purchase-requested", self._on_purchase_requested) app_manager.buy_app(app) self.assertTrue(self._purchase_requested_signal) do_events()
def test_app_icon_loading(self): # get icon self.set_mock_app_and_details( cached_icon_file_path="download-icon-test", icon="favicon.ico", icon_url="http://de.wikipedia.org/favicon.ico") self.view.show_app(self.view.app) do_events()
def test_edit_review_screen_has_right_labels(self): """Check that LP #880255 stays fixed. """ review_app = SubmitReviewsApp(datadir=REAL_DATA_DIR, app=None, parent_xid='', iconname='accessories-calculator', origin=None, version=None, action='modify', review_id=10000) # monkey patch away login to avoid that we actually login # and the UI changes because of that review_app.login = lambda: True # run the main app review_app.run() do_events() review_app.login_successful('foobar') do_events() self.assertEqual(_('Rating:'), review_app.rating_label.get_label()) self.assertEqual(_('Summary:'), review_app.review_summary_label.get_label()) self.assertEqual( _('Review by: %s') % 'foobar', review_app.review_label.get_label()) review_app.submit_window.hide()
def test_recommended_for_you_display_recommendations_not_opted_in(self): # we want to work in the "subcat" view self.notebook.next_page() do_events() visible = self.subcat_view.recommended_for_you_in_cat.get_property( "visible") self.assertFalse(visible)
def test_add_where_is_it(self): app = Application("", "software-center") self.view.show_app(app) self.view._add_where_is_it_commandline("apt") do_events() self.view._add_where_is_it_launcher( "/usr/share/applications/ubuntu-software-center.desktop") do_events()
def test_installedpane(self): win = windows.get_test_window_installedpane() self.addCleanup(win.destroy) pane = win.get_data("pane") # ensure it visible self.assertTrue(pane.get_property("visible")) # ensure the treeview is there and has data do_events() self.assertTrue(len(pane.treefilter.get_model()) > 2)
def test_reviews_no_reviews_but_app_not_installed(self, mock_connected): mock_connected.return_value = True # No reviews found, and the app isn't installed self.rl.clear() self.rl.configure_reviews_ui() do_events() self.assertEmbeddedMessageLabel( _("This app has not been reviewed yet"), _('You need to install this before you can review it'))
def _opt_in_and_populate_recommended_for_you_panel(self): # click the opt-in button to initiate the process self.rec_panel.opt_in_button.clicked() do_events() # simulate a successful opt-in by setting the recommender_uuid self.rec_panel.recommender_agent._set_recommender_uuid( "35fd653e67b14482b7a8b632ea90d1b6") # and update the recommended for you panel to load it up self.rec_panel._update_recommended_for_you_content() do_events()
def test_reviews_no_reviews_offer_to_write_one(self, mock_connected): mock_connected.return_value = True # No reviews found, and the app is installed self.rl.clear() self.rl._parent.app_details.pkg_state = PkgStates.INSTALLED self.rl.configure_reviews_ui() do_events() self.assertEmbeddedMessageLabel( _('Got an opinion?'), _('Be the first to contribute a review for this application'))
def test_show_recommendations_for_app(self, mock_query): self.view.show_app(self.app_mock) do_events() panel = self.view.recommended_for_app_panel panel._update_app_recommendations_content() do_events() # we fake the callback from the agent here panel.app_recommendations_cat._recommend_app_result(None, make_recommend_app_data()) self.assertNotEqual( panel.app_recommendations_cat.get_documents(self.db), [])
def test_show_recommendations_for_app(self, mock_query): self.view.show_app(self.app_mock) do_events() panel = self.view.recommended_for_app_panel panel._update_app_recommendations_content() do_events() # we fake the callback from the agent here panel.app_recommendations_cat._recommend_app_result( None, make_recommend_app_data()) self.assertNotEqual( panel.app_recommendations_cat.get_documents(self.db), [])
def test_reviews_offers_to_relax_language(self): # No reviews found, but there are some in other languages: self.rl.clear() self.rl.global_review_stats = Mock() self.rl.global_review_stats.ratings_total = 4 self.rl.configure_reviews_ui() do_events() self.assertEmbeddedMessageLabel( _("This app has not been reviewed yet in your language"), _('Try selecting a different language, or even "Any language"' ' in the language dropdown'))
def test_top_rated(self): # simulate review-stats refresh self.lobby._update_top_rated_content = Mock() self.lobby.reviews_loader.emit("refresh-review-stats-finished", []) self.assertTrue(self.lobby._update_top_rated_content.called) # test clicking top_rated self.lobby.connect("category-selected", self._on_category_selected) self.lobby.top_rated_frame.more.clicked() do_events() self.assertNotEqual(self._cat, None) self.assertEqual(self._cat.name, "Top Rated") self.assertEqual(self._cat.sortmode, SortMethods.BY_TOP_RATED)
def _simulate_install_events(self, app): # pretend we started an install self.rec_panel.backend.emit("transaction-started", app.pkgname, app.appname, "testid101", TransactionTypes.INSTALL) do_events_with_sleep() # send the signal to complete the install mock_result = Mock() mock_result.pkgname = app.pkgname self.rec_panel.backend.emit("transaction-finished", mock_result) do_events()
def test_new(self): # test db reopen triggers whats-new update self.lobby._update_whats_new_content = Mock() self.lobby.db.emit("reopen") self.assertTrue(self.lobby._update_whats_new_content.called) # test clicking new self.lobby.connect("category-selected", self._on_category_selected) self.lobby.whats_new_frame.more.clicked() do_events() self.assertNotEqual(self._cat, None) # encoding is utf-8 (since r2218, see category.py) self.assertEqual(self._cat.name, 'What\xe2\x80\x99s New') self.assertEqual(self._cat.sortmode, SortMethods.BY_CATALOGED_TIME)
def test_unity_launcher_integration_cancelled_install( self, mock_cancel_launcher): # test the automatic add to launcher enabled functionality when # installing an app from the details view, and then cancelling # the install (see LP: #1027209) self.config.add_to_unity_launcher = True test_pkgname = "software-center" app = Application("", test_pkgname) self.available_pane.app_view.emit("application-activated", app) do_events() self._simulate_install_events(app, result_event="transaction-cancelled") # ensure that we cancel the send self.assertTrue(mock_cancel_launcher.called)
def test_videoplayer(self): # show app with no video app = Application("", "2vcard") self.view.show_app(app) do_events() self.assertFalse(self.view.videoplayer.get_property("visible")) # create app with video and ensure its visible self.set_mock_app_and_details( app_name="synaptic", # this is a example html - any html5 video will do video_url="http://people.canonical.com/~mvo/totem.html") self.view.show_app(self.view.app) do_events() self.assertTrue(self.view.videoplayer.get_property("visible"))
def test_unity_launcher_integration_installation_failure( self, mock_cancel_launcher): # test the automatic add to launcher enabled functionality when # a failure is detected during the transaction (aptd emits a # "transaction-stopped" signal for this case) self.config.add_to_unity_launcher = True test_pkgname = "software-center" app = Application("", test_pkgname) self.available_pane.app_view.emit("application-activated", app) do_events() # aptd will emit a "transaction-stopped" signal if a transaction # error is encountered self._simulate_install_events(app, result_event="transaction-stopped") # ensure that we cancel the send self.assertTrue(mock_cancel_launcher.called)
def test_show_region_requirements(self): self.app_mock.details.region_requirements_satisfied = False self.view.show_app(self.app_mock) do_events() # ensure that the button is correct self.assertEqual(self.view.pkg_statusbar.button.get_label(), "Install Anyway") # and again for purchase self.app_mock.details.pkg_state = PkgStates.NEEDS_PURCHASE self.view.show_app(self.app_mock) self.assertEqual(self.view.pkg_statusbar.button.get_label(), _(u"Buy Anyway\u2026").encode("utf-8")) # check if the warning bar is displayed self.assertTrue(self.view.pkg_warningbar.get_property("visible")) self.assertEqual(self.view.pkg_warningbar.label.get_text(), REGION_WARNING_STRING)
def test_deb_file_view_error(self): mock_options = get_mock_options() app = SoftwareCenterAppGtk3(mock_options) app.run(["./data/test_debs/gdebi-test1.deb"]) # give it time for i in range(10): time.sleep(0.1) do_events() # its ok to break out early if app.available_pane.app_details_view and app.available_pane.app_details_view.get_property("visible"): break # check that we are on the right page self.assertEqual(app.available_pane.get_current_page(), AvailablePane.Pages.DETAILS) # this is deb that is not installable action_button = app.available_pane.app_details_view.pkg_statusbar.button self.assertFalse(action_button.get_property("visible"))
def test_unity_launcher_integration_cancelled_install(self, mock_cancel_launcher): # test the automatic add to launcher enabled functionality when # installing an app from the details view, and then cancelling # the install (see LP: #1027209) self.config.add_to_unity_launcher = True test_pkgname = "software-center" app = Application("", test_pkgname) self.available_pane.app_view.emit("application-activated", app) do_events() self._simulate_install_events(app, result_event="transaction-cancelled") # ensure that we cancel the send self.assertTrue( mock_cancel_launcher.called)
def test_show_region_requirements(self): self.app_mock.details.region_requirements_satisfied = False self.view.show_app(self.app_mock) do_events() # ensure that the button is correct self.assertEqual( self.view.pkg_statusbar.button.get_label(), "Install Anyway") # and again for purchase self.app_mock.details.pkg_state = PkgStates.NEEDS_PURCHASE self.view.show_app(self.app_mock) self.assertEqual( self.view.pkg_statusbar.button.get_label(), _(u"Buy Anyway\u2026").encode("utf-8")) # check if the warning bar is displayed self.assertTrue(self.view.pkg_warningbar.get_property("visible")) self.assertEqual(self.view.pkg_warningbar.label.get_text(), REGION_WARNING_STRING)
def test_recommended_for_you_display_recommendations(self): self._opt_in_and_populate_recommended_for_you_panel() # we fake the callback from the agent here for_you = self.rec_panel.recommended_for_you_cat for_you._recommend_me_result(None, make_recommender_agent_recommend_me_dict()) self.assertNotEqual(for_you.get_documents(self.db), []) self.assertEqual(self.rec_panel.spinner_notebook.get_current_page(), SpinnerNotebook.CONTENT_PAGE) do_events() # test clicking recommended_for_you More button self.lobby.connect("category-selected", self._on_category_selected) self.rec_panel.more.clicked() # this is delayed for some reason so we need to sleep here do_events_with_sleep() self.assertNotEqual(self._cat, None) self.assertEqual(self._cat.name, "Recommended For You")
def test_no_show_hardware_requirements(self): self.app_mock.details.hardware_requirements = {} self.app_mock.details.hardware_requirements_satisfied = True self.view.show_app(self.app_mock) do_events() # ensure we do not show anything if there are no HW requirements self.assertFalse(self.view.hardware_info.get_property("visible")) # ensure that the button is correct self.assertEqual(self.view.pkg_statusbar.button.get_label(), _("Install")) # and again for purchase self.app_mock.details.pkg_state = PkgStates.NEEDS_PURCHASE self.view.show_app(self.app_mock) self.assertEqual(self.view.pkg_statusbar.button.get_label(), _(u'Buy\u2026').encode("utf-8")) # check if the warning bar is invisible self.assertFalse(self.view.pkg_warningbar.get_property("visible"))
def test_unity_launcher_integration_installation_failure(self, mock_cancel_launcher): # test the automatic add to launcher enabled functionality when # a failure is detected during the transaction (aptd emits a # "transaction-stopped" signal for this case) self.config.add_to_unity_launcher = True test_pkgname = "software-center" app = Application("", test_pkgname) self.available_pane.app_view.emit("application-activated", app) do_events() # aptd will emit a "transaction-stopped" signal if a transaction # error is encountered self._simulate_install_events(app, result_event="transaction-stopped") # ensure that we cancel the send self.assertTrue( mock_cancel_launcher.called)
def test_deb_file_view_error(self): mock_options = get_mock_options() app = SoftwareCenterAppGtk3(mock_options) app.run(["./data/test_debs/gdebi-test1.deb"]) # give it time for i in range(10): time.sleep(0.1) do_events() # its ok to break out early if (app.available_pane.app_details_view and app.available_pane.app_details_view.get_property( "visible")): break # check that we are on the right page self.assertEqual(app.available_pane.get_current_page(), AvailablePane.Pages.DETAILS) # this is deb that is not installable action_button = app.available_pane.app_details_view.pkg_statusbar.button self.assertFalse(action_button.get_property("visible"))
def test_no_show_hardware_requirements(self): self.app_mock.details.hardware_requirements = {} self.app_mock.details.hardware_requirements_satisfied = True self.view.show_app(self.app_mock) do_events() # ensure we do not show anything if there are no HW requirements self.assertFalse( self.view.hardware_info.get_property("visible")) # ensure that the button is correct self.assertEqual( self.view.pkg_statusbar.button.get_label(), _("Install")) # and again for purchase self.app_mock.details.pkg_state = PkgStates.NEEDS_PURCHASE self.view.show_app(self.app_mock) self.assertEqual( self.view.pkg_statusbar.button.get_label(), _(u'Buy\u2026').encode("utf-8")) # check if the warning bar is invisible self.assertFalse(self.view.pkg_warningbar.get_property("visible"))
def _work(): new_text = widget.get_text() (view, enquirer) = data with ExecutionTime("total time"): with ExecutionTime("enquire.set_query()"): enquirer.set_query(get_query_from_search_entry(new_text), limit=100 * 1000, nonapps_visible=NonAppVisibility.ALWAYS_VISIBLE) store = view.tree_view.get_model() if store is None: return with ExecutionTime("store.clear()"): store.clear() with ExecutionTime("store.set_from_matches()"): store.set_from_matches(enquirer.matches) with ExecutionTime("model settle (size=%s)" % len(store)): do_events()
def test_appview_search_combo(self): # test if combox sort option "by relevance" vanishes for non-searches # LP: #861778 expected_normal = ["By Name", "By Top Rated", "By Newest First"] expected_search = [ "By Name", "By Top Rated", "By Newest First", "By Relevance" ] # setup goo win = get_test_window_appview() self.addCleanup(win.destroy) appview = win.get_data("appview") #entry = win.get_data("entry") do_events() # get the model model = appview.sort_methods_combobox.get_model() # test normal window (no search) matches = get_test_enquirer_matches(appview.helper.db) appview.display_matches(matches, is_search=False) appview.configure_sort_method(is_search=False) do_events() in_model = [] for item in model: in_model.append(model.get_value(item.iter, 0)) self.assertEqual(in_model, expected_normal) # now repeat and simulate a search matches = get_test_enquirer_matches(appview.helper.db) appview.display_matches(matches, is_search=True) appview.configure_sort_method(is_search=True) do_events() in_model = [] for item in model: in_model.append(model.get_value(item.iter, 0)) self.assertEqual(in_model, expected_search) # and back again to no search matches = get_test_enquirer_matches(appview.helper.db) appview.display_matches(matches, is_search=False) appview.configure_sort_method(is_search=False) do_events() # collect items in the model in_model = [] for item in model: in_model.append(model.get_value(item.iter, 0)) self.assertEqual(expected_normal, in_model)
def test_edit_review_screen_has_right_labels(self): """Check that LP #880255 stays fixed. """ review_app = SubmitReviewsApp(datadir=REAL_DATA_DIR, app=None, parent_xid='', iconname='accessories-calculator', origin=None, version=None, action='modify', review_id=10000) # monkey patch away login to avoid that we actually login # and the UI changes because of that review_app.login = lambda: True # run the main app review_app.run() do_events() review_app.login_successful('foobar') do_events() self.assertEqual(_('Rating:'), review_app.rating_label.get_label()) self.assertEqual(_('Summary:'), review_app.review_summary_label.get_label()) self.assertEqual(_('Review by: %s') % 'foobar', review_app.review_label.get_label()) review_app.submit_window.hide()
def test_app_view(self): enquirer = AppEnquire(self.cache, self.db) enquirer.set_query(xapian.Query(""), sortmode=SortMethods.BY_CATALOGED_TIME, limit=10, nonblocking_load=False) # get test window win = get_test_window_appview() self.addCleanup(win.destroy) appview = win.get_data("appview") # set matches appview.clear_model() appview.display_matches(enquirer.matches) do_events() # verify that the order is actually the correct one model = appview.tree_view.get_model() docs_in_model = [item[0] for item in model] docs_from_enquirer = [m.document for m in enquirer.matches] self.assertEqual(len(docs_in_model), len(docs_from_enquirer)) for i in range(len(docs_in_model)): self.assertEqual(self.db.get_pkgname(docs_in_model[i]), self.db.get_pkgname(docs_from_enquirer[i]))
def test_appview_search_combo(self): # test if combox sort option "by relevance" vanishes for non-searches # LP: #861778 expected_normal = ["By Name", "By Top Rated", "By Newest First"] expected_search = ["By Name", "By Top Rated", "By Newest First", "By Relevance"] # setup goo win = get_test_window_appview() self.addCleanup(win.destroy) appview = win.get_data("appview") #entry = win.get_data("entry") do_events() # get the model model = appview.sort_methods_combobox.get_model() # test normal window (no search) matches = get_test_enquirer_matches(appview.helper.db) appview.display_matches(matches, is_search=False) appview.configure_sort_method(is_search=False) do_events() in_model = [] for item in model: in_model.append(model.get_value(item.iter, 0)) self.assertEqual(in_model, expected_normal) # now repeat and simulate a search matches = get_test_enquirer_matches(appview.helper.db) appview.display_matches(matches, is_search=True) appview.configure_sort_method(is_search=True) do_events() in_model = [] for item in model: in_model.append(model.get_value(item.iter, 0)) self.assertEqual(in_model, expected_search) # and back again to no search matches = get_test_enquirer_matches(appview.helper.db) appview.display_matches(matches, is_search=False) appview.configure_sort_method(is_search=False) do_events() # collect items in the model in_model = [] for item in model: in_model.append(model.get_value(item.iter, 0)) self.assertEqual(expected_normal, in_model)
def test_recommended_for_you_display_recommendations_opted_in(self): self._opt_in_and_populate_recommended_for_you_panel() # we want to work in the "subcat" view self.notebook.next_page() rec_cat_panel = self.subcat_view.recommended_for_you_in_cat rec_cat_panel._update_recommended_for_you_content() do_events() # we fake the callback from the agent here rec_cat_panel.recommended_for_you_cat._recommend_me_result( None, make_recommender_agent_recommend_me_dict()) result_docs = rec_cat_panel.recommended_for_you_cat.get_documents( self.db) self.assertNotEqual(result_docs, []) # check that we are getting the correct number of results, # corresponding to the following Internet items: # Mangler, Midori, Midori Private Browsing, Psi self.assertTrue(len(result_docs) == 4) self.assertEqual(rec_cat_panel.spinner_notebook.get_current_page(), SpinnerNotebook.CONTENT_PAGE) # check that the tiles themselves are visible self.assertTrue(rec_cat_panel.recommended_for_you_content.get_property( "visible")) self.assertTrue(rec_cat_panel.recommended_for_you_content.get_children( )[0].title.get_property("visible")) # test clicking recommended_for_you More button self.subcat_view.connect( "category-selected", self._on_category_selected) rec_cat_panel.more.clicked() # this is delayed for some reason so we need to sleep here do_events_with_sleep() self.assertNotEqual(self._cat, None) self.assertEqual(self._cat.name, "Recommended For You in Internet")
def _install_from_list_view(self, pkgname): self.available_pane.notebook.set_current_page(AvailablePane.Pages.LIST) do_events() self.available_pane.on_search_terms_changed( None, "ark,artha,software-center") do_events() # select the first item in the list self.available_pane.app_view.tree_view.set_cursor( Gtk.TreePath(0), None, False) # ok to just use the test app here app = Application("", pkgname) do_events() self._simulate_install_events(app)
def test_track_db_open(self): tmpdir = tempfile.mkdtemp() tmpstamp = os.path.join(tmpdir, "update-stamp") open(tmpstamp, "w") softwarecenter.paths.APT_XAPIAN_INDEX_UPDATE_STAMP_PATH = tmpstamp softwarecenter.paths.APT_XAPIAN_INDEX_DB_PATH = \ softwarecenter.paths.XAPIAN_PATH db = get_test_db() db._axi_stamp_monitor = None db._on_axi_stamp_changed = Mock() self.assertFalse(db._on_axi_stamp_changed.called) db.open(use_axi=True) do_events() self.assertFalse(db._on_axi_stamp_changed.called) do_events() #print "modifiyng stampfile: ", tmpstamp os.utime(tmpstamp, (0, 0)) # wait up to 5s until the gvfs delivers the signal for i in range(50): do_events() time.sleep(0.1) if db._on_axi_stamp_changed.called: break self.assertTrue(db._on_axi_stamp_changed.called)
def _navigate_to_appdetails_and_install(self, pkgname): app = Application("", pkgname) self.available_pane.app_view.emit("application-activated", app) do_events() self._simulate_install_events(app)
def test_clear_credentials(self): clear_token_from_ubuntu_sso_sync("fo") do_events()
def test_spinner_available(self): win = get_test_window_globalpane() self.addCleanup(win.destroy) pane = win.get_data("pane") self.assertNotEqual(pane.spinner, None) do_events()
def test_page_pkgstates(self, mock_network_state_is_connected): mock_network_state_is_connected.return_value = True # show app app = Application("", "abiword") self.view.show_app(app) do_events() # check that the action bar is given initial focus in the view self.assertTrue(self.view.pkg_statusbar.button.is_focus()) # create mock app self.set_mock_app_and_details(app_name="abiword", purchase_date="2011-11-20 17:45:01", _error_not_found="error not found", price="US$ 1.00", pkgname="abiword", error="error-text") mock_app = self.view.app mock_details = self.view.app_details # the states and what labels we expect in the pkgstatusbar # first string is status text, second is button text pkg_states_to_labels = { PkgStates.INSTALLED: ("Purchased on 2011-11-20", "Remove"), PkgStates.UNINSTALLED: ('Free', 'Install'), PkgStates.NEEDS_PURCHASE: ('US$ 1.00', u'Buy\u2026'), PkgStates.PURCHASED_BUT_REPO_MUST_BE_ENABLED: ('Purchased on 2011-11-20', 'Install'), } # this describes if a button is visible or invisible button_invisible = [ PkgStates.ERROR, PkgStates.NOT_FOUND, PkgStates.INSTALLING_PURCHASED, PkgStates.PURCHASED_BUT_NOT_AVAILABLE_FOR_SERIES, PkgStates.UNKNOWN, ] # show a app through the various states and test if the right ui # elements are visible and have the right text for var in vars(PkgStates): state = getattr(PkgStates, var) mock_details.pkg_state = state # reset app to ensure its shown again self.view.app = None # show it self.view.show_app(mock_app) #do_events() # check button label if state in pkg_states_to_labels: label, button_label = pkg_states_to_labels[state] self.assertEqual(self.view.pkg_statusbar.get_label(), label.decode("utf-8")) self.assertEqual( self.view.pkg_statusbar.get_button_label().decode("utf-8"), button_label) # check if button should be there or not if state in button_invisible: self.assertFalse( self.view.pkg_statusbar.button.get_property("visible"), "button visible error for state %s" % state) else: self.assertTrue( self.view.pkg_statusbar.button.get_property("visible"), "button visible error for state %s" % state) # regression test for #955005 if state == PkgStates.NOT_FOUND: self.assertFalse(self.view.review_stats.get_visible()) self.assertFalse(self.view.reviews.get_visible())