def test_get_featured_front_page_returns_required_fields(self): """Test CACHE PROJECTS get_featured_front_page returns the required info about each featured project""" app = self.create_app(None) app.owner = self.user db.session.add(app) featured = Featured(app=app) db.session.add(featured) db.session.commit() fields = ('id', 'name', 'short_name', 'info', 'n_volunteers', 'n_completed_tasks') featured = cached_apps.get_featured_front_page()[0] for field in fields: assert featured.has_key(field), "%s not in app info" % field
def test_get_featured_front_page(self): """Test CACHE PROJECTS get_featured_front_page returns featured projects""" app = self.create_app(None) app.owner = self.user db.session.add(app) featured = Featured(app=app) db.session.add(featured) db.session.commit() featured = cached_apps.get_featured_front_page() assert len(featured) is 1, featured
def test_get_featured_front_page_not_returns_hidden_apps(self): """Test CACHE PROJECTS get_featured_front_page does not return hidden projects""" featured_app = self.create_app(None) featured_app.owner = self.user featured_app.hidden = 1 db.session.add(featured_app) featured = Featured(app=featured_app) db.session.add(featured) db.session.commit() featured = cached_apps.get_featured_front_page() assert len(featured) is 0, featured
def test_get_featured_front_page_only_returns_featured(self): """Test CACHE PROJECTS get_featured_front_page returns only featured projects""" featured_app = self.create_app(None) non_featured_app = self.create_app(None) non_featured_app.name = 'other_app' non_featured_app.short_name = 'other_app' featured_app.owner = self.user non_featured_app.owner = self.user db.session.add(featured_app) db.session.add(non_featured_app) featured = Featured(app=featured_app) db.session.add(featured) db.session.commit() featured = cached_apps.get_featured_front_page() assert len(featured) is 1, featured