def test_category_dynamic_categories(self, mock_get_region_cached): mock_get_region_cached.return_value = { "countrycode" : "us", } parser = CategoriesParser(self.db) cats = parser.parse_applications_menu(DATA_DIR, use_cache=False) cat = get_category_by_name(cats, 'Dynamic') self.assertEqual( "%s" % cat.query, "Xapian::Query((<alldocuments> AND XTregion::us))")
def test_category_dynamic_categories(self, mock_get_region_cached): mock_get_region_cached.return_value = { "countrycode": "us", } parser = CategoriesParser(self.db) cats = parser.parse_applications_menu("./data/") cat = get_category_by_name(cats, 'Dynamic') self.assertEqual("%s" % cat.query, "Xapian::Query((<alldocuments> AND XTregion::us))")
def _update_ceibal_apps_content(self): # remove any existing children from the grid widget LOG.debug("Adding Ceibal highlights pkgs to pane") self.ceibal_apps.remove_all() docs = self._ceibal_get_docs() self._add_tiles_to_flowgrid(docs, self.ceibal_apps, 8) self.ceibal_apps.show_all() ceibal_cat = get_category_by_name(self.categories, u"CeibalHighlights") # untranslated name return ceibal_cat
def _update_whats_new_content(self): # remove any existing children from the grid widget self.whats_new.remove_all() # get top_rated category and docs whats_new_cat = get_category_by_name( self.categories, u"What\u2019s New") # untranslated name if whats_new_cat: docs = whats_new_cat.get_documents(self.db) self._add_tiles_to_flowgrid(docs, self.whats_new, 8) self.whats_new.show_all() return whats_new_cat
def _update_top_rated_content(self): # remove any existing children from the grid widget self.top_rated.remove_all() # get top_rated category and docs top_rated_cat = get_category_by_name(self.categories, u"Top Rated") # untranslated name if top_rated_cat: docs = top_rated_cat.get_documents(self.db) self._add_tiles_to_flowgrid(docs, self.top_rated, TOP_RATED_CAROUSEL_LIMIT) self.top_rated.show_all() return top_rated_cat
def _update_top_rated_content(self): # remove any existing children from the grid widget self.top_rated.remove_all() # get top_rated category and docs top_rated_cat = get_category_by_name( self.categories, u"Top Rated") # untranslated name if top_rated_cat: docs = top_rated_cat.get_documents(self.db) self._add_tiles_to_flowgrid(docs, self.top_rated, TOP_RATED_CAROUSEL_LIMIT) self.top_rated.show_all() return top_rated_cat
def _update_whats_new_content(self): # remove any existing children from the grid widget self.whats_new.remove_all() # get top_rated category and docs whats_new_cat = get_category_by_name( self.categories, u"What\u2019s New") # untranslated name if whats_new_cat: docs = whats_new_cat.get_documents(self.db) self.whats_new.add_tiles(self.properties_helper, docs, WHATS_NEW_CAROUSEL_LIMIT) self.whats_new.show_all() return whats_new_cat
def _get_toprated_category_content(self): toprated_cat = get_category_by_name(self.categories, u"Top Rated") # unstranslated name if toprated_cat is None: LOG.warn("No 'toprated' category found!!") return None, [] enq = AppEnquire(self.cache, self.db) app_filter = AppFilter(self.db, self.cache) enq.set_query(toprated_cat.query, limit=TOP_RATED_CAROUSEL_LIMIT, sortmode=toprated_cat.sortmode, filter=app_filter, nonapps_visible=NonAppVisibility.ALWAYS_VISIBLE, nonblocking_load=False) if not hasattr(self, "helper"): self.helper = AppPropertiesHelper(self.db, self.cache, self.icons) return toprated_cat, enq.get_documents()
def _get_new_category_content(self): whatsnew_cat = get_category_by_name( self.categories, u"What\u2019s New") # unstranslated name if whatsnew_cat is None: LOG.warn("No 'new' category found!!") return None, [] enq = AppEnquire(self.cache, self.db) app_filter = AppFilter(self.db, self.cache) app_filter.set_available_only(True) app_filter.set_not_installed_only(True) enq.set_query(whatsnew_cat.query, limit=8, filter=app_filter, sortmode=SortMethods.BY_CATALOGED_TIME, nonapps_visible=NonAppVisibility.ALWAYS_VISIBLE, nonblocking_load=False) if not hasattr(self, "helper"): self.helper = AppPropertiesHelper(self.db, self.cache, self.icons) return whatsnew_cat, enq.get_documents()
def _get_new_category_content(self): whatsnew_cat = get_category_by_name(self.categories, u"What\u2019s New") # unstranslated name if whatsnew_cat is None: LOG.warn("No 'new' category found!!") return None, [] enq = AppEnquire(self.cache, self.db) app_filter = AppFilter(self.db, self.cache) app_filter.set_available_only(True) app_filter.set_not_installed_only(True) enq.set_query(whatsnew_cat.query, limit=8, filter=app_filter, sortmode=SortMethods.BY_CATALOGED_TIME, nonapps_visible=NonAppVisibility.ALWAYS_VISIBLE, nonblocking_load=False) if not hasattr(self, "helper"): self.helper = AppPropertiesHelper(self.db, self.cache, self.icons) return whatsnew_cat, enq.get_documents()
def test_category_debtags(self): cat = get_category_by_name(self.cats, 'Debtag') self.assertEqual( "%s" % cat.query, "Xapian::Query((<alldocuments> AND XTregion::de))")
def test_get_documents(self): cat = get_category_by_name(self.cats, 'Featured') docs = cat.get_documents(self.db) self.assertNotEqual(docs, []) for doc in docs: self.assertEqual(type(doc), xapian.Document)
def test_cat_has_flags(self): cat = get_category_by_name(self.cats, 'Featured') self.assertEqual(cat.flags[0], 'carousel-only')
def test_get_cat_by_name(self): cat = get_category_by_name(self.cats, 'Games') self.assertEqual(cat.untranslated_name, 'Games') cat = get_category_by_name(self.cats, 'Featured') self.assertEqual(cat.untranslated_name, 'Featured')
def test_category_debtags(self): cat = get_category_by_name(self.cats, 'Debtag') self.assertEqual("%s" % cat.query, "Xapian::Query((<alldocuments> AND XTregion::de))")